通过transfrom属性进行2D转换
html代码:
<section id=box> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>1</li> </ul> </section>
CSS代码:
<style> * { margin: 0; padding: 0; font-family: 微软雅黑; list-style: none; } #box{ width:400px; height:200px; border: 1px solid #000; margin: 50px auto; overflow: hidden; } ul{ width: 2000px; animation: dh 10s infinite ease; } ul li{ width:400px; height:200px; float: left; } ul li:nth-child(1){ background:#4b86db; } ul li:nth-child(2){ background:#ff9999; } ul li:nth-child(3){ background:olivedrab; } ul li:nth-child(4){ background:skyblue; } ul li:nth-child(5){ background:#4b86db; } @keyframes dh { 0%{transform: translateX(0)} 25%{transform: translateX(-400px)} 50%{transform: translateX(-800px)} 75%{transform: translateX(-1200px)} 100%{transform: translateX(-1600px)} } </style>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)