1. 程式人生 > >動畫實現無縫滾動

動畫實現無縫滾動

<style>
*{
padding: 0;
margin: 0;
}
div{
width: 882px;
height: 86px;
margin:100px auto;
background-color: #ddd;
overflow: hidden;
}
div >ul{
width: 200%;
list-style: none;
/*1.設定的名稱*/
animation-name: move;
/*2.設定動畫的耗時*/
animation-duration: 8s;
/*3.市場無限迴圈*/
animation-iteration-count: infinite;
/*4.設定時間函式*/
animation-timing-function: linear;
}

div > ul > li{
width:126px;
float: left;
}
div > ul > li > img{
width:100%;
}
/*滑鼠上移,停止動畫*/
div:hover > ul{
cursor: pointer;
animation-play-state: paused;
}

/*建立動畫*/
@keyframes move {
from{
transform: translateX(0);
}
to{
transform: translateX(-882px);
}
}
</style>
</head>
<body>
<div>
<ul>
<li><img src="images/img/1.jpg" alt=""></li>
<li><img src="images/img/2.jpg" alt=""></li>
<li><img src="images/img/3.jpg" alt=""></li>
<li><img src="images/img/4.jpg" alt=""></li>
<li><img src="images/img/5.jpg" alt=""></li>
<li><img src="images/img/6.jpg" alt=""></li>
<li><img src="images/img/7.jpg" alt=""></li>
<li><img src="images/img/1.jpg" alt=""></li>
<li><img src="images/img/2.jpg" alt=""></li>
<li><img src="images/img/3.jpg" alt=""></li>
<li><img src="images/img/4.jpg" alt=""></li>
<li><img src="images/img/5.jpg" alt=""></li>
<li><img src="images/img/6.jpg" alt=""></li>
<li><img src="images/img/7.jpg" alt=""></li>
</ul>
</div>