js原生之焦点图转换加定时器实例
(编辑:jimmy 日期: 2024/11/18 浏览:3 次 )
在jQuery之焦点图转换-左右的基础上,将jQuery代码改成js原生,并添加定时器(setInterval()和clearInterval())
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>焦点图转换--原生和定时器</title> <link rel="stylesheet" href="css/reset.css"> <style type="text/css"> .pic-show{width: 480px;overflow: hidden;} #pic{width: 1920px;height: 320px;position: relative;} #pic img{display: block;float: left;} .pic-show>img{display: block;cursor: pointer;opacity: 0.8; position: absolute;top: 142px;left: 30px;} .pic-show>img:last-child{display: block; position: absolute;left: 414px; } ul{width: 120px;height: 18px;position: absolute;top: 280px;left: 185px;} li{float: left;width: 20px;height: 18px;margin-left: 5px;} a{display: block;width: 20px;height: 18px;text-decoration: none;border: 1px solid #ccc;border-radius: 50%;background-color: #ccc;opacity: 0.6;} a:hover{background-color: #094a99;} .aCss{background-color: #094a99;} p{width: 480px;text-align: center;} </style> </head> <body> <div class="pic-show"> <div id="pic"> <img src="/UploadFiles/2021-04-02/1.jpg">以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!
下一篇:IntersectionObserver API 详解篇