html css js 制作网页banner滑块显示-代码设计网页前端设计cid1052

css

  1. body,
  2. html,
  3. .seq {
  4. /* #1 */
  5. width: 100%;
  6. height: 100%;
  7. /* #2 */
  8. margin: 0;
  9. padding: 0;
  10. }
  11. .seq {
  12. /* #1 */
  13. position: relative;
  14. overflow: hidden;
  15. font-family: sans-serif;
  16. color: white;
  17. text-align: center;
  18. background-color: #2A93BC;
  19. transition-duration: .5s;
  20. transition-property: background-color;
  21. }
  22. .seq-canvas,
  23. .seq-canvas > * {
  24. /* #1 */
  25. height: 100%;
  26. width: 100%;
  27. /* #2 */
  28. margin: 0;
  29. padding: 0;
  30. list-style: none;
  31. }
  32. .seq-canvas > * {
  33. /* #1 */
  34. position: absolute;
  35. /* #2 */
  36. padding: 32px;
  37. box-sizing: border-box;
  38. /* #3 */
  39. height: auto;
  40. top: 0;
  41. bottom: 80px;
  42. }
  43. .seq-step1 {
  44. background-color: #102334;
  45. }
  46. .seq-step2 {
  47. background-color:#1f1f1f;
  48. }
  49. .seq-step3 {
  50. background-color: #561295;
  51. }
  52. .feature {
  53. width: 70%;
  54. max-width: 100%;
  55. height: auto;
  56. }
  57. @media only screen and (min-width: 460px) and (min-height: 520px) {
  58. .feature {
  59. width: 100%;
  60. }
  61. }
  62. /* Ghost element */
  63. .valign:before {
  64. content: "";
  65. height: 100%;
  66. }
  67. /* Vertically align the ghost and desired elements */
  68. .valign:before,
  69. .valign > .vcenter {
  70. display: inline-block;
  71. vertical-align: middle;
  72. }
  73. /* Remove 4px gap to allow consistent valign */
  74. .valign {
  75. font-size: 0;
  76. }
  77. /* Reset font-size on valigned elements */
  78. .valign > .vcenter {
  79. font-size: 16px;
  80. }
  81. .title {
  82. /* #1 */
  83. margin: 0;
  84. /* #2 */
  85. opacity: 0;
  86. transform: translateX(50px) translateZ(0);
  87. /* #3 */
  88. transition-duration: .5s;
  89. transition-property: opacity, transform;
  90. }
  91. /*
  92. * When a step is active, fade in to opaque and slide to the center
  93. */
  94. .seq-in .title {
  95. opacity: 1;
  96. transform: translateX(0) translateZ(0);
  97. }
  98. .seq-out .title {
  99. opacity: 0;
  100. transform: translateX(-50px) translateZ(0);
  101. }
  102. .feature {
  103. transform: translateZ(0) scale(0);
  104. transition-duration: .5s;
  105. transition-property: transform, opacity;
  106. }
  107. .seq-in .feature {
  108. transform: translateZ(0) scale(1);
  109. }
  110. .seq-out .feature {
  111. transform: translateZ(0) scale(1);
  112. opacity: 0;
  113. }
  114. .nav {
  115. /* #1 */
  116. position: absolute;
  117. z-index: 100;
  118. left: 0;
  119. right: 0;
  120. bottom: 2.5em;
  121. max-width: 640px;
  122. width: 100%;
  123. border: none;
  124. margin: 0 auto;
  125. padding: 0;
  126. }
  127. .seq-next,
  128. .seq-prev {
  129. /* #1 */
  130. padding: 0;
  131. background: transparent;
  132. border: none;
  133. /* #2 */
  134. padding: .75em;
  135. cursor: pointer;
  136. color: white;
  137. font-size: .75em;
  138. text-transform: uppercase;
  139. /* #3 */
  140. opacity: .7;
  141. transition-duration: .25s;
  142. transition-property: opacity;
  143. }
  144. .seq-next:hover,
  145. .seq-prev:hover {
  146. opacity: 1;
  147. }
  148. .seq-next,
  149. .seq-prev,
  150. .seq-pagination {
  151. position: relative;
  152. display: inline-block;
  153. vertical-align: middle;
  154. margin-top: 0;
  155. }
  156. .seq-pagination {
  157. margin: 0 1em;
  158. padding: 0;
  159. }
  160. .seq-pagination li {
  161. /* #1 */
  162. position: relative;
  163. /* #2 */
  164. list-style: none;
  165. /* #3 */
  166. display: inline-block;
  167. vertical-align: middle;
  168. /* #4 */
  169. width: 50px;
  170. height: 40px;
  171. margin: 0 .25em;
  172. }
  173. .seq-pagination li:before {
  174. /* #1 */
  175. content: "";
  176. display: block;
  177. position: absolute;
  178. top: 100%;
  179. left: 50%;
  180. width: 6px;
  181. height: 6px;
  182. margin-left: -3px;
  183. margin-top: .5em;
  184. border-radius: 50%;
  185. background: white;
  186. /* #2 */
  187. opacity: 0;
  188. transition-duration: .25s;
  189. transition-property: opacity;
  190. }
  191. /*
  192. * Show the indicator dot for the current link
  193. */
  194. .seq-pagination .seq-current:before {
  195. opacity: .7;
  196. }
  197. /*
  198. * Reset styles
  199. */
  200. .seq-pagination img,
  201. .seq-pagination a {
  202. display: block;
  203. border: none;
  204. }
body,
html,
.seq {

  /* #1 */
  width: 100%;
  height: 100%;

  /* #2 */
  margin: 0;
  padding: 0;
}
 
.seq {

  /* #1 */
  position: relative; 
  overflow: hidden; 
  font-family: sans-serif;
  color: white;
  text-align: center; 
  background-color: #2A93BC; 
  transition-duration: .5s;
  transition-property: background-color;
}
 
.seq-canvas,
.seq-canvas > * {

  /* #1 */
  height: 100%;
  width: 100%;

  /* #2 */
  margin: 0;
  padding: 0;
  list-style: none;
}

 
.seq-canvas > * {
  /* #1 */
  position: absolute;

  /* #2 */
  padding: 32px;
  box-sizing: border-box;

  /* #3 */
  height: auto;
  top: 0;
  bottom: 80px;
}

.seq-step1 {
  background-color: #102334; 
}

.seq-step2 {
  background-color:#1f1f1f;
}

.seq-step3 {
  background-color: #561295;
}

.feature {
  width: 70%;
  max-width: 100%;
  height: auto;
}

@media only screen and (min-width: 460px) and (min-height: 520px) {
  .feature {
    width: 100%;
  }
}


/* Ghost element */
.valign:before {
  content: "";
  height: 100%;
}

/* Vertically align the ghost and desired elements */
.valign:before,
.valign > .vcenter {
  display: inline-block;
  vertical-align: middle;
}

/* Remove 4px gap to allow consistent valign */
.valign {
  font-size: 0;
}

/* Reset font-size on valigned elements */
.valign > .vcenter {
  font-size: 16px;
}
 
.title {
  /* #1 */
  margin: 0;

  /* #2 */
  opacity: 0;
  transform: translateX(50px) translateZ(0);

  /* #3 */
  transition-duration: .5s;
  transition-property: opacity, transform;
}

/*
 * When a step is active, fade in to opaque and slide to the center
 */
.seq-in .title {
  opacity: 1;
  transform: translateX(0) translateZ(0);
}
 
.seq-out .title {
  opacity: 0;
  transform: translateX(-50px) translateZ(0);
}

 
.feature {
  transform: translateZ(0) scale(0);
  transition-duration: .5s;
  transition-property: transform, opacity;
}

 
.seq-in .feature {
  transform: translateZ(0) scale(1);
}
 
.seq-out .feature {
  transform: translateZ(0) scale(1);
  opacity: 0;
}
 
.nav {
  /* #1 */
  position: absolute;
  z-index: 100;
  left: 0;
  right: 0;
  bottom: 2.5em;
  max-width: 640px;
  width: 100%;
 
  border: none;
  margin: 0 auto;
  padding: 0;
}

 
.seq-next,
.seq-prev {
  /* #1 */
  padding: 0;
  background: transparent;
  border: none;

  /* #2 */
  padding: .75em;
  cursor: pointer;
  color: white;
  font-size: .75em;
  text-transform: uppercase;

  /* #3 */
  opacity: .7;
  transition-duration: .25s;
  transition-property: opacity;
}

.seq-next:hover,
.seq-prev:hover {
  opacity: 1;
}
 
.seq-next,
.seq-prev,
.seq-pagination {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  margin-top: 0;
}
 
.seq-pagination {
  margin: 0 1em;
  padding: 0;
}
 
.seq-pagination li {
  /* #1 */
  position: relative;

  /* #2 */
  list-style: none;

  /* #3 */
  display: inline-block;
  vertical-align: middle;

  /* #4 */
  width: 50px;
  height: 40px;
  margin: 0 .25em;
}
 
.seq-pagination li:before {
  /* #1 */
  content: "";
  display: block;
  position: absolute;
  top: 100%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  margin-top: .5em;
  border-radius: 50%;
  background: white;

  /* #2 */
  opacity: 0;
  transition-duration: .25s;
  transition-property: opacity;
}

/*
 * Show the indicator dot for the current link
 */
.seq-pagination .seq-current:before {
  opacity: .7;
}

/*
 * Reset styles
 */
.seq-pagination img,
.seq-pagination a {
  display: block;
  border: none;
}

html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <link rel="stylesheet" href="main.css">
  7. </head>
  8. <body>
  9. <div id="sequence" class="seq">
  10. <ul class="seq-canvas">
  11. <li class="step1 valign seq-in">
  12. <div class="vcenter">
  13. <img data-seq class="feature" src="bmw.png" width="389" height="300" />
  14. <h2 data-seq class="title">BMW Nova</h2>
  15. </div>
  16. </li>
  17. <li class="step2 valign">
  18. <div class="vcenter">
  19. <img data-seq class="feature" src="bmw1.png" width="325" height="300" />
  20. <h2 data-seq class="title">Blue Bmw</h2>
  21. </div>
  22. </li>
  23. <li class="step3 valign">
  24. <div class="vcenter">
  25. <img data-seq class="feature" src="bmw2.png" width="325" height="300" />
  26. <h2 data-seq class="title">Coming up</h2>
  27. </div>
  28. </li>
  29. </ul>
  30. <fieldset class="nav" aria-label="Slider buttons" aria-controls="sequence">
  31. <button type="button" class="seq-prev" aria-label="Previous"><img src="prev.svg" alt="Previous" /></button>
  32. <ul role="navigation" aria-label="Pagination" class="seq-pagination">
  33. <li class="seq-current">
  34. <a href="#step1" rel="step1" title="Go to bananas">
  35. <img src="bmw.png" alt="Bananas" width="50" height="40" />
  36. </a>
  37. </li>
  38. <li>
  39. <a href="#step2" rel="step2" title="Go to coconut">
  40. <img src="bmw1.png" alt="Coconut" width="50" height="40" />
  41. </a>
  42. </li>
  43. <li>
  44. <a href="#step3" rel="step3" title="Go to orange">
  45. <img src="bmw2.png" alt="Orange" width="50" height="40" />
  46. </a>
  47. </li>
  48. </ul>
  49. <button type="button" class="seq-next" aria-label="Next"><img src="next.svg" alt="Next" /></button>
  50. </fieldset>
  51. </div>
  52. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/4.1.4/imagesloaded.min.js"></script>
  53. <script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
  54. <script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/154/sequence.min.2.1.0.js"></script>
  55. <script>
  56. var sequenceElement = document.getElementById("sequence");
  57. var options = {
  58. keyNavigation: true,
  59. animateCanvas: false,
  60. phaseThreshold: false,
  61. reverseWhenNavigatingBackwards: true
  62. }
  63. var mySequence = sequence(sequenceElement, options);
  64. </script>
  65. </body>
  66. </html>
 <!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <title>Document</title>
      <link rel="stylesheet" href="main.css">
 </head>
 <body>
     <div id="sequence" class="seq">
    <ul class="seq-canvas">
      <li class="step1 valign seq-in">
        <div class="vcenter">
          <img data-seq class="feature" src="bmw.png" width="389" height="300" />
          <h2 data-seq class="title">BMW Nova</h2>
        </div>
      </li>
      <li class="step2 valign">
        <div class="vcenter">
          <img data-seq class="feature" src="bmw1.png" width="325" height="300" />
          <h2 data-seq class="title">Blue Bmw</h2>
        </div>
      </li>
      <li class="step3 valign">
        <div class="vcenter">
          <img data-seq class="feature" src="bmw2.png" width="325" height="300" />
          <h2 data-seq class="title">Coming up</h2>
        </div>
      </li>
    </ul>

    <fieldset class="nav" aria-label="Slider buttons" aria-controls="sequence">

      <button type="button" class="seq-prev" aria-label="Previous"><img src="prev.svg" alt="Previous" /></button>

      <ul role="navigation" aria-label="Pagination" class="seq-pagination">
        <li class="seq-current">
          <a href="#step1" rel="step1" title="Go to bananas">
            <img src="bmw.png" alt="Bananas" width="50" height="40" />
          </a>
        </li>
        <li>
          <a href="#step2" rel="step2" title="Go to coconut">
            <img src="bmw1.png" alt="Coconut" width="50" height="40" />
          </a>
        </li>
        <li>
          <a href="#step3" rel="step3" title="Go to orange">
            <img src="bmw2.png" alt="Orange" width="50" height="40" />
          </a>
        </li>
      </ul>

      <button type="button" class="seq-next" aria-label="Next"><img src="next.svg" alt="Next" /></button>
    </fieldset>

  </div>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/4.1.4/imagesloaded.min.js"></script>
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
  
  <script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/154/sequence.min.2.1.0.js"></script>
  <script>
     var sequenceElement = document.getElementById("sequence");

var options = {
  keyNavigation: true,
  animateCanvas: false,
  phaseThreshold: false,
  reverseWhenNavigatingBackwards: true
}

var mySequence = sequence(sequenceElement, options);
     
    </script>
 </body>
 </html>

在线演示? 让链接同时具备两种打开方式

获取源码: Mov
下载数:67人次, 文件大小: 891.7 KB, 上传日期: 2020年-11 月-26日

公众号回复:gcode  获取解压密码

qrcode_for_gh_6ea2c28a1709_258 (1)

2,485 人查阅

类似文章