swiper-分页标签内加time时间进度条

效果图-样式颜色很丑,需要的请自行优化
swiper-分页标签内加time时间进度条_第1张图片


DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <title>Swiper demotitle>
  <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
  
  <link rel="stylesheet" href="assets/styles/other/swiper-bundle.min.css" />

  
  <style>
    html,
    body {
      position: relative;
      height: 100%;
    }

    body {
      background: #eee;
      font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
      font-size: 14px;
      color: #000;
      margin: 0;
      padding: 0;
    }

    .swiper {
      width: 100%;
      height: 100%;
    }

    .swiper-slide {
      text-align: center;
      font-size: 18px;
      background: #fff;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .swiper-slide img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .swiper-slide::before{
        content: '';
        left: 0;
        top: 0;
        width: 100%;
        height: 2px;
        background-color: #000;
        position: absolute;
        transform: scaleX(0);
        transform-origin: left;
        z-index: 3;
        transition-timing-function: linear;
    }
    .swiper-pagination-bullet{
        background-color: transparent;
        opacity: 1;
        margin: 0 6px !important;
        width: 60px;
        height: 9px;
        position: relative;
        outline: none;
        vertical-align: middle;
    }
    .swiper-pagination-bullet span{
        width: 60px;
        height: 3px;
        background-color: #ccc;
        display: block;
        margin-top: 3px;
    }
    .swiper-pagination-bullet i{
        background-color: #000;
        height: 3px;
        width: 60px;
        position: absolute;
        top: 4px;
        transform: scaleX(0);
        transform-origin: left;
        z-index: 3;
        transition-timing-function: linear;
    }
    .swiper-pagination-bullet-active i{
        animation: middle 5s forwards;//与autoplay delay的时间保持一致
    }
    @keyframes middle{
        0%{
            transform: scaleX(0);
            left: 0;
        }
        100%{
            transform: scaleX(1);
            left: 0;
        }
    }
  style>
head>

<body>
  <div class="swiper mySwiper">
    <div class="swiper-wrapper">
      <div class="swiper-slide">Slide 1div>
      <div class="swiper-slide">Slide 2div>
      <div class="swiper-slide">Slide 3div>
      <div class="swiper-slide">Slide 4div>
      <div class="swiper-slide">Slide 5div>
      <div class="swiper-slide">Slide 6div>
      <div class="swiper-slide">Slide 7div>
      <div class="swiper-slide">Slide 8div>
      <div class="swiper-slide">Slide 9div>
    div>
    <div class="swiper-pagination">div>
  div>

  
  <script src="assets/scripts/other/swiper-bundle.min.js">script>

  
  <script>
    var swiper = new Swiper(".mySwiper", {
      autoplay: {
        delay: 5000,
      },
      pagination: {
        el: ".swiper-pagination",
        clickable: true,
        renderBullet: function (index, className) {
            return '
+ className + '">
'
; }, }, });
script> body> html>

你可能感兴趣的:(css,javascript,前端)