Погрузчик с пятью стойками

Я создал загрузчик в css с тремя полосами, код приведен ниже. Планки основаны на :before и :after. Но если мне нужен погрузчик с пятью барами, как я могу это сделать?

.loader,
.loader:before,
.loader:after {
    background: black;
    -webkit-animation: load1 1s infinite ease-in-out;
    animation: load1 1s infinite ease-in-out;
    width: 1em;
    height: 4em;
}

.loader {
    color: black;
    text-indent: -9999em;
    margin-top: 10px;
    margin-right: auto;
    margin-bottom: 10px;
    margin-left: auto;
    position: relative;
    font-size: 8px;
    -webkit-transform: translateZ(0);
    -ms-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-animation-delay: -0.16s;
    animation-delay: -0.16s;
}

.loader:before,
.loader:after {
    position: absolute;
    top: 0;
    content: '';
}

.loader:before {
    left: -2em;
    -webkit-animation-delay: -0.32s;
    animation-delay: -0.32s;
}

.loader:after {
    left: 2em;
}

@-webkit-keyframes load1 {
    0%,
    80%,
    100% {
        box-shadow: 0 0;
        height: 4em;
    }
    40% {
        box-shadow: 0 -2em;
        height: 5em;
    }
}

@keyframes load1 {
    0%,
    80%,
    100% {
        box-shadow: 0 0;
        height: 4em;
    }
    40% {
        box-shadow: 0 -2em;
        height: 5em;
    }
}

.loader-wrapper {
    display: block;
    position: relative;
    height: 56px;
}
<div class = "loader-wrapper">
  <div class = "loader">Loading...</div>
</div>
Улучшение производительности загрузки с помощью Google Tag Manager и атрибута Defer
Улучшение производительности загрузки с помощью Google Tag Manager и атрибута Defer
В настоящее время производительность загрузки веб-сайта имеет решающее значение не только для удобства пользователей, но и для ранжирования в...
Введение в CSS
Введение в CSS
CSS является неотъемлемой частью трех основных составляющих front-end веб-разработки.
Как выровнять Div по центру?
Как выровнять Div по центру?
Чтобы выровнять элемент <div>по горизонтали и вертикали с помощью CSS, можно использовать комбинацию свойств и значений CSS. Вот несколько методов,...
Навигация по приложениям React: Исчерпывающее руководство по React Router
Навигация по приложениям React: Исчерпывающее руководство по React Router
React Router стала незаменимой библиотекой для создания одностраничных приложений с навигацией в React. В этой статье блога мы подробно рассмотрим...
Система управления парковками с использованием HTML, CSS и JavaScript
Система управления парковками с использованием HTML, CSS и JavaScript
Веб-сайт по управлению парковками был создан с использованием HTML, CSS и JavaScript. Это простой сайт, ничего вычурного. Основная цель -...
Toor - Ангулярный шаблон для бронирования путешествий
Toor - Ангулярный шаблон для бронирования путешествий
Toor - Travel Booking Angular Template один из лучших Travel & Tour booking template in the world. 30+ валидированных HTML5 страниц, которые помогут...
1
0
99
5
Перейти к ответу Данный вопрос помечен как решенный

Ответы 5

Вы должны использовать этот убийственный способ.

Пожалуйста, добавьте новый класс, например: <div class = "loader more">Loading...</div>

И дайте этот тип css:

.loader.more {
    position: absolute;
    right: 0;
    left: 95px;
    top: -10px;
}
.loader.more:after {
    left: 0;
}

Надеюсь на эту помощь.

Дайте мне знать дальнейшие разъяснения.

  .loader,
.loader:before,
.loader:after {
    background: black;
    -webkit-animation: load1 1s infinite ease-in-out;
    animation: load1 1s infinite ease-in-out;
    width: 1em;
    height: 4em;
}

.loader {
    color: black;
    text-indent: -9999em;
    margin-top: 10px;
    margin-right: auto;
    margin-bottom: 10px;
    margin-left: auto;
    position: relative;
    font-size: 8px;
    -webkit-transform: translateZ(0);
    -ms-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-animation-delay: -0.16s;
    animation-delay: -0.16s;
}

.loader:before,
.loader:after {
    position: absolute;
    top: 0;
    content: '';
}

.loader:before {
    left: -2em;
    -webkit-animation-delay: -0.32s;
    animation-delay: -0.32s;
}

.loader:after {
    left: 2em;
}

@-webkit-keyframes load1 {
    0%,
    80%,
    100% {
        box-shadow: 0 0;
        height: 4em;
    }
    40% {
        box-shadow: 0 -2em;
        height: 5em;
    }
}

@keyframes load1 {
    0%,
    80%,
    100% {
        box-shadow: 0 0;
        height: 4em;
    }
    40% {
        box-shadow: 0 -2em;
        height: 5em;
    }
}

.loader-wrapper {
    display: block;
    position: relative;
    height: 56px;
}
.loader.more {
    position: absolute;
    right: 0;
    left: 95px;
    top: -10px;
}
.loader.more:after {
    left: 0;
}
<div class = "loader-wrapper">
  <div class = "loader">Loading...</div>
  <div class = "loader more">Loading...</div>
</div>

Я только что пробовал, не знаю, что это идеальное решение.

 .loader,
    .loader1,
    .loader:before,
    .loader1:before,
    .loader:after
     {
        background: black;
        -webkit-animation: load1 1s infinite ease-in-out;
        animation: load1 1s infinite ease-in-out;
        width: 1em;
        height: 4em;
    }

    .loader,.loader1 {
        color: black;
        text-indent: -9999em;
        margin-top: 10px;
        margin-right: auto;
        margin-bottom: 10px;
        margin-left: auto;
        position: relative;
        font-size: 8px;
        -webkit-transform: translateZ(0);
        -ms-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-animation-delay: -0.16s;
        animation-delay: -0.16s;
    }

    .loader:before,
    .loader1:before,
    .loader:after {
        position: absolute;
        top: 0;
        content: '';
    }

    .loader:before, .loader1:before {
        left: -2em;
        -webkit-animation-delay: -0.32s;
        animation-delay: -0.32s;
    }

    .loader:after {
        left: 2em;
    }

    @-webkit-keyframes load1 {
        0%,
        80%,
        100% {
            box-shadow: 0 0;
            height: 4em;
        }
        40% {
            box-shadow: 0 -2em;
            height: 5em;
        }
    }

    @keyframes load1 {
        0%,
        80%,
        100% {
            box-shadow: 0 0;
            height: 4em;
        }
        40% {
            box-shadow: 0 -2em;
            height: 5em;
        }
    }

    .loader-wrapper {
        display: block;
        position: relative;
        height: 56px;
    }

     .loader
      {
        position: relative;
        left: 30px;
        top: -45px;      
      }
    <div class = "loader-wrapper">
<div class = "loader1">Loading...</div>
      <div class = "loader">Loading...</div>
    </div>
Ответ принят как подходящий

Вы можете использовать CSS ntnchild. Ваш HTML и CSS будут такими:

.loading-bar {
  display: inline-block;
  width: 4px;
  height: 18px;
  border-radius: 4px;
  animation: loading 1s ease-in-out infinite;
}

.loading-bar:nth-child(1) {
  background-color: #3498db;
  animation-delay: 0;
}

.loading-bar:nth-child(2) {
  background-color: #c0392b;
  animation-delay: 0.09s;
}

.loading-bar:nth-child(3) {
  background-color: #f1c40f;
  animation-delay: .18s;
}

.loading-bar:nth-child(4) {
  background-color: #27ae60;
  animation-delay: .27s;
}

.loading-bar:nth-child(5) {
  background-color: #000000;
  animation-delay: .36s;
}

@keyframes loading {
  0% {
    transform: scale(1);
  }

  20% {
    transform: scale(1, 2.2);
  }

  40% {
    transform: scale(1);
  }
}
<div class = "loading">
    <div class = "loading-bar"></div>
    <div class = "loading-bar"></div>
    <div class = "loading-bar"></div>
    <div class = "loading-bar"></div>
    <div class = "loading-bar"></div>
</div>

Вы можете легко сделать это, используя только один элемент и градиент. Вам просто нужно управлять background-size, чтобы получить нужную анимацию.

.loader {
    width: 70px;
    height: 4em;
    margin: 10px auto;
    background-image:
      linear-gradient(black,black),
      linear-gradient(black,black),
      linear-gradient(black,black),
      linear-gradient(black,black),
      linear-gradient(black,black);
    background-size:10px 100%;
    background-position:
      0 50%,
      15px 50%,
      30px 50%,
      45px 50%,
      60px 50%;
    background-repeat:no-repeat;
    animation:load 2s infinite linear;
}
@keyframes load{
  0% {
     background-size:10px 100%,10px 100%,10px 100%,10px 100%,10px 100%;
  }
  15% {
     background-size:10px  50%,10px 100%,10px 100%,10px 100%,10px 100%;
  }
  30% {
     background-size:10px  80%,10px  50%,10px 100%,10px 100%,10px 100%;
  }
  45% {
     background-size:10px 100%,10px  80%,10px  50%,10px 100%,10px 100%;
  }
  60% {
     background-size:10px 100%,10px 100%,10px  80%,10px  50%,10px 100%;
  }
  75% {
     background-size:10px 100%,10px 100%,10px 100%,10px  80%,10px  50%;
  }
  90% {
     background-size:10px 100%,10px 100%,10px 100%,10px 100%,10px  80%;
  }
  100% {
     background-size:10px 100%,10px 100%,10px 100%,10px 100%,10px 100%;
  }
}
<div class = "loader"></div>

Я создал загрузчик с использованием шести стержней. Используя CSS, вы настраиваете конкретный div для задержки анимации. Как @ João Pedro Schmitz предлагает использовать селектор nth-child CSS для выбора div. Я даю пробел 10px после каждого div и запускаю анимацию каждого div с задержкой .12s.

/* This provide animated ajax loading image. */
.animatedBox {
  display: inline-block;
  position: relative;
  width: 20px;
  height: 20px;
}

.animatedBox div {
  display: inline-block;
  position: absolute;
  left: 6px;
  width: 6px;
  background: #fff;
  animation: animatedBox 2s cubic-bezier(0, 0.5, 0.5, 1) infinite;
}

.animatedBox div:nth-child(1) {
  left: 20px;
  animation-delay: -0.60s;
}

.animatedBox div:nth-child(2) {
  left: 30px;
  animation-delay: -0.48s;
}

.animatedBox div:nth-child(3) {
  left: 40px;
  animation-delay: -0.36s;
}

.animatedBox div:nth-child(4) {
  left: 50px;
  animation-delay: -0.24s;
}

.animatedBox div:nth-child(5) {
  left: 60px;
  animation-delay: -0.12s;
}

.animatedBox div:nth-child(6) {
  left: 70px;
  animation-delay: 0;
}
@-webkit-keyframes animatedBox {
0% {
    top: 0px;
    height: 30px;
    background: #333;
  }
  50%,100% {
    top: 0px;
    height: 10px;
	background: #333;
  }	
}
@keyframes animatedBox {
  0% {
    top: -11px;
    height: 45px;
    background: #333;
  }
  50%,100% {
    top: 0px;
    height: 25px;
	background: #333;
  }
}
<div class = "animatedBox">
	<div></div>
	<div></div>
	<div></div>
	<div></div>
	<div></div>
	<div></div>
</div>

Другие вопросы по теме