用CSS代码编写简易轮播图
2019-12-25 00:02
1446 查看
废话不多说,直接上代码
<!doctype html> <html> <head> <title></title> <meta charset="utf-8" /> <style type="text/css"> .container{ width: 1000px; height: 500px; margin: 50px auto; overflow: hidden; background: skyblue; } .flex{ display: flex; } .item-box{ animation: my-css 5s infinite; -webkit-animation: my-css 5s infinite; -o-animation: my-css 5s infinite; -moz-animation: my-css 5s infinite; animation-direction: alternate; -webkit-animation-direction: alternate; -o-animation-direction: alternate; -moz-animation-direction: alternate; } .item-box:hover{ animation-play-state: paused; -webkit-animation-play-state: paused; -o-animation-play-state: paused; -moz-animation-play-state: paused; } .item-box div{ width: 1000px; height: 450px; flex-shrink: 0; } .item1{ background: pink; } .item2{ background: brown; } .item3{ background: red; } .item4{ background: yellow; } .item5{ background: green; } @keyframes my-css{ 0% { transform: translate(0%); } 25% { transform: translate(-100%); } 50% { transform: translate(-200%); } 75% { transform: translate(-300%); } 100% { transform: translate(-400%); } } @-webkit-keyframes my-css{ 0% { transform: translate(0%); } 25% { transform: translate(-100%); } 50% { transform: translate(-200%); } 75% { transform: translate(-300%); } 100% { transform: translate(-400%); } } @-o-keyframes my-css{ 0% { transform: translate(0%); } 25% { transform: translate(-100%); } 50% { transform: translate(-200%); } 75% { transform: translate(-300%); } 100% { transform: translate(-400%); } } @-moz-keyframes my-css{ 0% { transform: translate(0%); } 25% { transform: translate(-100%); } 50% { transform: translate(-200%); } 75% { transform: translate(-300%); } 100% { transform: translate(-400%); } } .ico-box{ width: 30%; height: 30px; justify-content: space-around; align-items: center; margin: 10px auto; } .ico-box div{ height: 10px; width: 20px; border-radius: 10px; background: #fff; transition: width 0.5s; } .ico-box div:hover{ width: 40px; background: pink; } </style> </head> <body> <div class="container"> <div class="item-box flex"> <div class="item1"></div> <div class="item2"></div> <div class="item3"></div> <div class="item4"></div> <div class="item5"></div> </div> <div class="ico-box flex"> <div class="ico"></div> <div class="ico"></div> <div class="ico"></div> <div class="ico"></div> <div class="ico"></div> </div> </div> </body> </html>
相关文章推荐
- 借助 SublimeLinter 编写高质量的 JavaScript & CSS 代码
- 让代码飞一会儿:快速编写 HTML 和 CSS 的工具和技术
- 任务02——安装 Intellj IDEA,编写一个简易四则运算小程序,并将代码提交到 GitHub
- 标准的CSS代码编写习惯:两列左导航设计,顶
- 编写手机端自适应页面案例,springMVC代码,SpringMVC上传代码,去掉input框中原有的样式,使ios按钮没有圆角,css中的border-radius类似
- 编写跨浏览器兼容的 CSS 代码的金科玉律
- 可读性CSS代码编写的小技巧
- Zen Coding: 一种快速编写HTML/CSS代码的方法
- 编写出色CSS代码的13个建议
- CSS代码编写中视觉格式化模型的学习教程
- 用Sublime Text搭建简易IDE编写Verilog代码
- Zen Coding: 一种快速编写HTML/CSS代码的方法
- 通用base.css —— 《编写高质量代码 web前端开发修炼之道》
- 编写灵活、稳定、高质量的 HTML 和 CSS 代码的规范
- 20个编写现代CSS代码的建议
- 前端开发必备 40款优秀CSS代码编写工具推荐
- Emmet:HTML/CSS代码快速编写神器
- 如何提升我的HTML&CSS技术,编写有结构的代码
- 借助 SublimeLinter 编写高质量的 JavaScript & CSS 代码
- Emmet:HTML/CSS代码快速编写神器使用教程