圖片輪播是網(wǎng)頁(yè)上經(jīng)常使用的效果,今天W3Cschool小編給大家簡(jiǎn)單介紹一下圖片滾動(dòng)鼠標(biāo)經(jīng)過(guò)停止效果如何用代碼實(shí)現(xiàn),使用CSS+DIV+Jquery很容易就能實(shí)現(xiàn),一起來(lái)看看吧!
HTML:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>不間斷圖片滾動(dòng)在線(xiàn)演示 - 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="http://m.hgci.cn/" target="_blank"><img src="images/1.jpg" />
<span>w3cschool</span></a></div>
<div><a href="#" target="_blank"><img src="images/2.jpg" />
<span>演示內(nèi)容</span></a></div>
<div><a href="#" target="_blank"><img src="images/3.jpg" />
<span>演示內(nèi)容</span></a></div>
<div><a href="#" target="_blank"><img src="images/4.jpg" />
<span>演示內(nèi)容</span></a></div>
<div><a href="#" target="_blank"><img src="images/5.jpg" />
<span>演示內(nèi)容</span></a></div>
<div><a href="#" target="_blank"><img src="images/6.jpg" />
<span>演示內(nèi)容</span></a></div>
<div><a href="#" target="_blank"><img src="images/7.jpg" />
<span>演示內(nèi)容</span></a></div>
<div><a href="#" target="_blank"><img src="images/8.jpg" />
<span>演示內(nèi)容</span></a></div>
<div><a href="#" target="_blank"><img src="images/9.jpg" />
<span>演示內(nèi)容</span></a></div>
</li>
</ul>
</div>
</div>
</body>
</html>
在以上的html代碼中,每組DIV對(duì)應(yīng)圖文數(shù)據(jù),可按需增減,margin_right屬性控制圖文的間距,speed屬性控制輪播的速度。
CSS:
@charset "utf-8";
/* m.hgci.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;}
圖片滾動(dòng)切換效果代碼就給大家分享到這里了,希望能對(duì)各位有所幫助,更多編程的學(xué)習(xí)請(qǐng)關(guān)注 W3Cschool 官網(wǎng)。