原生js实现一个幻灯片效果代码
代码语言:html
所属分类:幻灯片
代码描述:原生js实现一个幻灯片效果代码
代码标签: 原生js实现一个幻灯片效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { display: flex; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(to right, #3494e6, #ec6ead); } .wrapper { border-radius: 10px; box-shadow: 0 20px 20px 0 rgba(0, 0, 0, 0.3); border: 2px solid transparent; } .carousel { position: relative; width: 500px; height: 300px; border-radius: 10px; overflow: hidden; } .slide { position: absolute; width: 100%; height: 100%; transition: left 200ms ease-in-out; } .slide img { width: 100%; height: auto; display: block; } .btn { all: unset; position: absolute; top: 0; bottom: 0; margin: auto; z-index: 100; fill: white; padding: 1rem; cursor: pointer; } .prev { left: 0; } .next { right: 0; } .prev:hover { background-image: linear-gradient(-90deg, rgba(0, 0, 0, 0.2), transparent); } .next:hover { background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.2), transparent); } </style> </head> <body> <div class="wrapper"> <div class="carousel"> <button class="btn prev"> <svg width="24" height="24" viewBox="0 0 24 24"> <path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" /> <path d="M0 0h24v24H0z" fill="none" /> </svg> </button> <div class="slide"> <img src="//repo.bfw.wiki/bfwrepo/image/638cb7c6a5dc2.png" alt="Slide 1"> </div>.........完整代码请登录后点击上方下载按钮下载查看
网友评论0