jquery实现上下滚动广告效果代码实例
Admin 2021-04-02 群英技术资讯 898 次浏览
我们在浏览网站时,经常会看到滚动广告,那么这是怎么样实现的呢?这篇文章就给大家介绍一下jquery实现上下滚动的效果,文章中有详细的代码示例,对此感兴趣的朋友就继续往下看吧。
一、jquery上下滚动预约记录
jquery广告上下滚动效果,直接上代码
代码如下(示例):
CSS:
<style> /* -------------------------预约记录----------------------------------- */ .Top_Record{} .topRec_List dl,.maquee{ width:90%; overflow:hidden; margin:0 auto; color:#7C7C7C} .maquee{ height:265px;} .topRec_List ul{ width:100%; height:195px;} .topRec_List li{ height:35px;font-size:14px;width: 100% } /*.topRec_List li:nth-child(2n){ background:#077cd0}*/ .topRec_List li div{ float:left;} .topRec_List li div:nth-child(1){ width:35%;} .topRec_List li div:nth-child(2){ width:35%;} .topRec_List li div:nth-child(3){ width:20%;} .maquee ul li{float: left} .active{ color: #FC6A13; } </style>
HTML:
<div style="background: #ffffff;width: 100%;margin-top: 5pt;padding-bottom: 10pt;padding-top: 5pt"> <div class="titled"><p class="person">已有235人看房</p><p class="titleds">预约记录</p></div> <br> <div class="Top_Record"> <div class="topRec_List"> <dl> {{-- <dd> </dd>--}} </dl> <div class="maquee"> <ul> <li><div>张三1</div><div>131****121</div><div>10分钟前</div></li> <li><div>张三2</div><div>131****121</div><div>10分钟前</div></li> <li><div>张三3</div><div>131****121</div><div>10分钟前</div></li> </ul> </div> </div> </div> </div>
JS:
<script type="text/javascript"> const index = ($(".maquee").height() / $(".maquee ul li").height()); function autoScroll(obj){ $(obj).find("ul").animate({ marginTop : "-35px" },1000,function(){ $(this).css({marginTop : "0px"}).find("li:first").appendTo(this); }) $(".maquee ul li").removeClass('active'); $(".maquee ul li").eq(parseInt(index)+1).addClass('active') } $(function(){ var scroll=setInterval('autoScroll(".maquee")',1500); }); $(".maquee ul li").eq(parseInt(index)+1).addClass('active') </script>
二、效果
以上就是jquery实现上下滚动广告的全部内容,希望对大家学习jquery知识有所帮助,大家也能够参考上述思考一下如何实现左右滚动的广告效果。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
blur当元素失去焦点时触发。focus当元素获得焦点时触发。focusin等于focus事件,但它冒泡。focusout是HTML事件blur的通用版本。
本文主要介绍了JavaScript如何用面向对象的方式封装拖拽对象,通过3种方式来实现,帮助读者更好的理解其原理
这篇文章主要介绍了vue的webcamjs集成方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
这篇文章主要为大家详细介绍了小程序实现tab更换页面效果,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
这篇文章主要介绍了在Angular项目使用socket.io实现通信的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008