赞
踩
-
- <!DOCTYPE html>
- <html lang="en">
-
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>纯CSS实现轮播图(自动轮播)</title>
- <link rel="stylesheet" href="../css/reset.css">
- <link rel="stylesheet" href="../css/autoMatic.css">
- </head>
-
- <body>
- <!-- 创建外部展示容器 -->
- <div class="banner-container">
- <!-- 创建图片存储容器 -->
- <div class="banner-img-container">
- <img src="../img/banner01.png" alt="">
- <img src="../img/banner02.png" alt="">
- <img src="../img/banner03.png" alt="">
- <img src="../img/banner04.png" alt="">
- <img src="../img/banner05.png" alt="">
- </div>
- </div>
- </body>
-
- </html>
autoMatic.css
- @charset "utf-8";
- /* CSS Document */
-
- /* 自动轮播样式 */
- .banner-container{
- width:1200px;
- height:400px;
- /* 轮播图居中 */
- margin:1rem auto;
- /* 隐藏超出展示容器的内容 */
- overflow: hidden;
- position: relative;
- }
-
- .banner-container .banner-img-container {
- width:6000px;
- height:400px;
- overflow: hidden;
- position: absolute;
- /* 开启弹性盒,让图片横向排列 */
- display: flex;
- animation: run 10s ease infinite;
- }
-
- .banner-container .banner-img-container img{
- width:1200px;
- height:100%;
- }
-
- /* 动画关键帧 */
- @keyframes run {
- 0%,10%{
- /* margin-left: 0; */
- transform: translateX(0);
- }
- 20%,30%{
- /* margin-left: -1200px;; */
- transform: translateX(-1200px);
- }
- 40%,50%{
- /* margin-left: -2400px; */
- transform: translateX(-2400px);
- }
- 60%,70%{
- /* margin-left: -3600px; */
- transform: translateX(-3600px);
- }
- 80%,90%{
- /* margin-left: -4800px; */
- transform: translateX(-4800px);
- }
- 100%{
- /* margin-left: 0; */
- transform: translateX(0);
- }
- }
reset.css
- @charset "utf-8";
- /* CSS Document */
-
- html, body, div, span, applet, object, iframe,
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
- a, abbr, acronym, address, big, cite, code,
- del, dfn, em, img, ins, kbd, q, s, samp,
- small, strike, strong, sub, sup, tt, var,
- b, u, i, center,
- dl, dt, dd, ol, ul, li,
- fieldset, form, label, legend,
- table, caption, tbody, tfoot, thead, tr, th, td,
- article, aside, canvas, details, embed,
- figure, figcaption, footer, header, hgroup,
- menu, nav, output, ruby, section, summary,
- time, mark, audio, video {
- margin: 0;
- padding: 0;
- border: 0;
- font-size: 100%;
- font: inherit;
- vertical-align: baseline;
- }
- /* HTML5 display-role reset for older browsers */
- article, aside, details, figcaption, figure,
- footer, header, hgroup, menu, nav, section {
- display: block;
- }
- body {
- line-height: 1;
- }
- ol, ul {
- list-style: none;
- }
- blockquote, q {
- quotes: none;
- }
- blockquote:before, blockquote:after,
- q:before, q:after {
- content: '';
- content: none;
- }
- table {
- border-collapse: collapse;
- border-spacing: 0;
- }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。