首页 / CSS / jq和css自制轮播效果代码分享
jq和css自制轮播效果代码分享
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了jq和css自制轮播效果代码分享,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2288字,纯文字阅读大概需要4分钟。
内容图文
![jq和css自制轮播效果代码分享](/upload/InfoBanner/zyjiaocheng/295/e6b135e03c8e4d8b8ab7895610377b97.jpg)
html部分:
<p class="banner1"> <p class="imgbox1"> <a href="#"><img src="img/detail1.jpg" alt="这是我定义的第一张图"></a> <a href="#"><img src="img/project1.png" alt="这是我定义的第二张图"></a> <a href="#"><img src="img/aboutus.png" alt="这是我定义的第三张图"></a> </p> <!-- 图片盒子 end --> <p class="title1"> <span>这是我定义的第一张图</span> <span>这是我定义的第二张图</span> <span>这是我定义的第三张图</span> </p> </p> <ul class="circle1"> <li class="circle_active"></li> <li></li> <li></li> </ul><!-- 圆点下标 end -->
css部分:
.banner1 { width: 100%; height: 4rem; overflow: hidden; margin: 0 auto; position: relative; } .imgbox1 { height: 7.5rem; position: absolute; left: 0; overflow: hidden; background: #fff; } .imgbox1 img { width: 100%; float: left; }
.title1 { width: 100%; position: absolute; bottom: 0px; padding: .25rem .2rem; box-sizing: border-box; background: rgba(255, 255, 255, 0.8); } .title1>span { color: #000000; display: block; text-align: center; } .circle1 { width: 1.5rem; margin: .2rem auto 0; } .circle1 li { width: .2rem; height: .2rem; margin: .1rem 5px; cursor: pointer; display: inline-block; background: #CCCCCC; border-radius: 50%; } .circle_active { background: #575757 !important; }
js部分:
var imgindex=$('.imgbox1').find('a').index() var titleindex=$('.title1').find('span').index(); $(window).ready(function(){ $('.title1').find('span').eq(0).show(); $('.title1').find('span').eq(0).siblings().hide(); }) $('.circle1').on('click','li',function(){ var circleindx=$(this).index(); imgindex=circleindx; titleindex=circleindx; $(this).addClass('circle_active'); $(this).siblings().removeClass('circle_active'); $('.imgbox1').find('a').eq(imgindex).show(300); $('.imgbox1').find('a').eq(imgindex).siblings().hide(); $('.title1').find('span').eq(titleindex).show(); $('.title1').find('span').eq(titleindex).siblings().hide(); }) function autoplay(){ timer=setInterval(function(){ imgindex++; var circles=$('.circle1').find('li'); if(imgindex>circles.length-1){ imgindex=0; } circles.eq(imgindex).trigger("click"); },2000); } autoplay()
相关推荐:
react轮播图组件react-slider-light详解
JS实现图片轮播的实例
jquery实现PC端轮播图代码
以上就是jq和css自制轮播效果代码分享的详细内容,更多请关注Gxl网其它相关文章!
内容总结
以上是互联网集市为您收集整理的jq和css自制轮播效果代码分享全部内容,希望文章能够帮你解决jq和css自制轮播效果代码分享所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。