图片轮播是网页上经常使用的效果,今天W3Cschool小编给大家简单介绍一下图片滚动鼠标经过停止效果如何用代码实现,使用CSS+DIV+Jquery很容易就能实现,一起来看看吧!
HTML:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>不间断图片滚动在线演示 - W3Cschool</title>
<link href="images/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script src="jQuery-jcMarquee.js" type="text/javascript"></script>
<script>
$(function(){
$('#Marquee_x').jcMarquee({ 'marquee':'x','margin_right':'10px','speed':10 });
});
</script>
</head>
<body>
<div id="mrq">
<div id="Marquee_x">
<ul>
<li>
<div>
<a href="https://www.w3cschool.cn/" target="_blank"><img src="images/1.jpg" />
<span>w3cschool</span></a></div>
<div><a href="#" target="_blank"><img src="images/2.jpg" />
<span>演示内容</span></a></div>
<div><a href="#" target="_blank"><img src="images/3.jpg" />
<span>演示内容</span></a></div>
<div><a href="#" target="_blank"><img src="images/4.jpg" />
<span>演示内容</span></a></div>
<div><a href="#" target="_blank"><img src="images/5.jpg" />
<span>演示内容</span></a></div>
<div><a href="#" target="_blank"><img src="images/6.jpg" />
<span>演示内容</span></a></div>
<div><a href="#" target="_blank"><img src="images/7.jpg" />
<span>演示内容</span></a></div>
<div><a href="#" target="_blank"><img src="images/8.jpg" />
<span>演示内容</span></a></div>
<div><a href="#" target="_blank"><img src="images/9.jpg" />
<span>演示内容</span></a></div>
</li>
</ul>
</div>
</div>
</body>
</html>
在以上的html代码中,每组DIV对应图文数据,可按需增减,margin_right属性控制图文的间距,speed属性控制轮播的速度。
CSS:
@charset "utf-8";
/* www.w3cschool.cn */
body, div, ul, li{margin:0; padding:0;font-style: normal;font:12px/22px "\5B8B\4F53",Arial, Helvetica, sans-serif}
ol, ul ,li{list-style:none}
img {border: 0; vertical-align:middle}
body{color:#000000;background:#FFF; text-align:center}
.clear{clear:both;height:1px;width:100%; overflow:hidden; margin-top:-1px}
a{color:#000000;text-decoration:none}
a:hover{color:#BA2636;text-decoration:underline}
#mrq{width:900px; margin:20px auto;border:1px solid #000; padding:2px}
#Marquee_x { overflow:hidden; width: 900px }
#Marquee_x ul li ,#Marquee_x ul li div{ float:left;line-height:25px;overflow:hidden}
#Marquee_x ul li div{ float:left;line-height:25px;height:130px; width:140px; overflow:hidden}
#Marquee_x ul li div img{ border:1px solid #DADADA; width:130px; height:100px; display:block}
#Marquee_x ul li div span{ display:block;}
图片滚动切换效果代码就给大家分享到这里了,希望能对各位有所帮助,更多编程的学习请关注 W3Cschool 官网。