jQuery实现模拟marquee标签效果

2020-05-23 06:10:57易采站长站整理

Marquee

      模仿IE下面的marquee效果,鼠标移上去暂停。形成环的主要原理在于每张图片一旦判断出了外面的显示窗口就添加到尾部,用append和prepend模拟数组的push()和shift()。

     

HTML


<!doctype html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="" name="keywords" />
<meta content="" name="description" />
<meta name="author" content="codetker" />
<head>
<title>模拟marquee标签效果的简单实现</title>
<link href="style/reset.css" rel="stylesheet" type="text/css">
<link href="style/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery.codetker.marquee.js"></script>
</head>

<body>
<div class="wrap">
<div class="marquee">
<ul>
<li>
<a href="" title="">1
<img src="images/test.jpg" alt="">
</a>
</li>
<li>
<a href="" title="">2
<img src="images/test.jpg" alt="">
</a>
</li>
<li>
<a href="" title="">3
<img src="images/test.jpg" alt="">
</a>
</li>
<li>
<a href="" title="">4
<img src="images/test.jpg" alt="">
</a>
</li>
<li>
<a href="" title="">5
<img src="images/test.jpg" alt="">
</a>
</li>
<li>
<a href="" title="">6
<img src="images/test.jpg" alt="">
</a>
</li>
<li>
<a href="" title="">7
<img src="images/test.jpg" alt="">
</a>
</li>
<li>
<a href="" title="">8
<img src="images/test.jpg" alt="">
</a>
</li>
</ul>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$(".marquee").marquee();
});
</script>
</body>
</html>

CSS


@charset "utf-8";
/* CSS Document */
body{
margin:0 0;
padding:0 0;
height:100%;
width:100%;
}
.wrap{
font-family:"微软雅黑","宋体", Times, "Times New Roman", serif;