@lexstile

Как сделать поочередную смену background блоков на css?

Есть такая структура:
<div class="preloader">
    <div class="circle"></div>
    <div class="circle"></div>
    <div class="circle"></div>
</div>

Как можно организовать поочередную смену бэграунда каждого блока с классом circle? (При этом зациклив ее)
  • Вопрос задан
  • 99 просмотров
Решения вопроса 1
0xD34F
@0xD34F Куратор тега CSS
<div class="preloader">
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
</div>

.circle {
  background: grey;
  display: inline-block;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: preloader 1s infinite linear;
}

.circle:nth-child(1) { animation-delay: 0s; }
.circle:nth-child(2) { animation-delay: 0.2s; }
.circle:nth-child(3) { animation-delay: 0.4s; }

@keyframes preloader {
  0%, 40% {
    background: grey;
  }
  20% {
    background: black;
  }
}
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы