自学html/css,写了几个简单的小案例,供大家参考,也希望大家能指点在下的不足之处,我会尽力改进.
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>无缝滚动</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
@keyframes moving{
from {
transform: translateX(0);
}
to {
transform: translateX(-1000px);
}
}
img {
width: 200px;
height: 150px;
}
body {
background-color: #eee;
}
nav {
width: 1000px;
height: 150px;
border: 2px solid #fafafa;
margin: 100px auto;
overflow: hidden;
}
nav ul {
list-style: none;
overflow: hidden;
animation: moving 7s linear infinite;
width: 200%;
}
nav:hover ul {
animation-play-state: paused;
}
nav ul li {
float: left;
}
nav li a {
display: block;
width: 200px;
height: 150px;
}
</style>
</head>
<body>
<!--无缝滚动开始啦-->
<nav>
<ul>
<!--第一组开始-->
<li>
<a href="#">
<img src="img/1.jpg" />
</a>
</li>
<li>
<a href="#">
<img src="img/2.jpg" />
</a>
</li>
<li>
<a href="#">
<img src="img/3.jpg" />
</a>
</li>
<li>
<a href="#">
<img src="img/4.jpg" />
</a>
</li>
<li>
<a href="#">
<img src="img/5.jpg" />
</a>
</li>
<!--第一组结束-->
<!--第二组开始-->
<li>
<a href="#">
<img src="img/1.jpg" />
</a>
</li>
<li>
<a href="#">
<img src="img/2.jpg" />
</a>
</li>
<li>
<a href="#">
<img src="img/3.jpg" />
</a>
</li>
<li>
<a href="#">
<img src="img/4.jpg" />
</a>
</li>
<li>
<a href="#">
<img src="img/5.jpg" />
</a>
</li>
<!--第二组结束-->
</ul>
</nav>
<!--无缝滚动结束啦-->
</body>
</html>
图片素材用大家自己的即可,结构已经搭建好.