原生js实现图片点击放大缩小效果代码
代码语言:html
所属分类:图片放大
代码描述:原生js实现图片点击放大缩小效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> /* (A) LIGHTBOX BACKGROUND */ #lightbox { /* (A1) COVERS FULLSCREEN */ position: fixed; z-index: 999; margin:0 auto; width: 100vw; height: 100vh; top:0;bottom:0;left:0;right:0; /* (A2) BACKGROUND */ background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; align-items: center; /* (A4) HIDDEN BY DEFAULT */ visibility: hidden; opacity: 0; /* (A5) SHOW/HIDE ANIMATION */ transition: opacity ease 0.4s; } .zoom {cursor: zoom-in;} .show {cursor: zoom-out;} /* (A6) TOGGLE VISIBILITY */ #lightbox.show { visibility: visible; opacity: 1; } /* (B) LIGHTBOX IMAGE */ #lightbox img { /* (B1) DIMENSIONS */ width: 100%; background-position: center; background-repeat: no-repeat; /* (B2) IMAGE FIT */ /* conta.........完整代码请登录后点击上方下载按钮下载查看
网友评论0