当前位置:   article > 正文

HTML自动轮播图_自动轮播图html代码

自动轮播图html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>纯CSS实现轮播图(自动轮播)</title>
  7. <link rel="stylesheet" href="../css/reset.css">
  8. <link rel="stylesheet" href="../css/autoMatic.css">
  9. </head>
  10. <body>
  11. <!-- 创建外部展示容器 -->
  12. <div class="banner-container">
  13. <!-- 创建图片存储容器 -->
  14. <div class="banner-img-container">
  15. <img src="../img/banner01.png" alt="">
  16. <img src="../img/banner02.png" alt="">
  17. <img src="../img/banner03.png" alt="">
  18. <img src="../img/banner04.png" alt="">
  19. <img src="../img/banner05.png" alt="">
  20. </div>
  21. </div>
  22. </body>
  23. </html>

autoMatic.css

  1. @charset "utf-8";
  2. /* CSS Document */
  3. /* 自动轮播样式 */
  4. .banner-container{
  5. width:1200px;
  6. height:400px;
  7. /* 轮播图居中 */
  8. margin:1rem auto;
  9. /* 隐藏超出展示容器的内容 */
  10. overflow: hidden;
  11. position: relative;
  12. }
  13. .banner-container .banner-img-container {
  14. width:6000px;
  15. height:400px;
  16. overflow: hidden;
  17. position: absolute;
  18. /* 开启弹性盒,让图片横向排列 */
  19. display: flex;
  20. animation: run 10s ease infinite;
  21. }
  22. .banner-container .banner-img-container img{
  23. width:1200px;
  24. height:100%;
  25. }
  26. /* 动画关键帧 */
  27. @keyframes run {
  28. 0%,10%{
  29. /* margin-left: 0; */
  30. transform: translateX(0);
  31. }
  32. 20%,30%{
  33. /* margin-left: -1200px;; */
  34. transform: translateX(-1200px);
  35. }
  36. 40%,50%{
  37. /* margin-left: -2400px; */
  38. transform: translateX(-2400px);
  39. }
  40. 60%,70%{
  41. /* margin-left: -3600px; */
  42. transform: translateX(-3600px);
  43. }
  44. 80%,90%{
  45. /* margin-left: -4800px; */
  46. transform: translateX(-4800px);
  47. }
  48. 100%{
  49. /* margin-left: 0; */
  50. transform: translateX(0);
  51. }
  52. }

reset.css

  1. @charset "utf-8";
  2. /* CSS Document */
  3. html, body, div, span, applet, object, iframe,
  4. h1, h2, h3, h4, h5, h6, p, blockquote, pre,
  5. a, abbr, acronym, address, big, cite, code,
  6. del, dfn, em, img, ins, kbd, q, s, samp,
  7. small, strike, strong, sub, sup, tt, var,
  8. b, u, i, center,
  9. dl, dt, dd, ol, ul, li,
  10. fieldset, form, label, legend,
  11. table, caption, tbody, tfoot, thead, tr, th, td,
  12. article, aside, canvas, details, embed,
  13. figure, figcaption, footer, header, hgroup,
  14. menu, nav, output, ruby, section, summary,
  15. time, mark, audio, video {
  16. margin: 0;
  17. padding: 0;
  18. border: 0;
  19. font-size: 100%;
  20. font: inherit;
  21. vertical-align: baseline;
  22. }
  23. /* HTML5 display-role reset for older browsers */
  24. article, aside, details, figcaption, figure,
  25. footer, header, hgroup, menu, nav, section {
  26. display: block;
  27. }
  28. body {
  29. line-height: 1;
  30. }
  31. ol, ul {
  32. list-style: none;
  33. }
  34. blockquote, q {
  35. quotes: none;
  36. }
  37. blockquote:before, blockquote:after,
  38. q:before, q:after {
  39. content: '';
  40. content: none;
  41. }
  42. table {
  43. border-collapse: collapse;
  44. border-spacing: 0;
  45. }

img

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/803767
推荐阅读
相关标签
  

闽ICP备14008679号