1

Как можно реализовать анимацию заполнение трубы, как на сайте gulp.
Может быть у кого-нибудь есть примеры кода по реализации данной анимации введите сюда описание изображения

2
  • Пожалуйста, уточните вашу конкретную проблему или приведите более подробную информацию о том, что именно вам нужно. В текущем виде сложно понять, что именно вы спрашиваете. 3 окт 2021 в 17:58
  • С помощью svg, как там и сделано.
    – hlearn
    3 окт 2021 в 18:42

1 ответ 1

6

банальнейшая трансформация фона, градиента или псевдоэлемента с задержкой анимации для разных блоков. Вот вам кусок, дальше сами, плиз =)

:root {
  --bg: #ccc;
  --color: #CC444A;
  --flowlength: 200px;
  --flowlengthminus: -200px;
}

@keyframes flow {
  from {
    right: 100%;
    left: var(--flowlengthminus);
  }
  to {
    left: 100%;
    right: var(--flowlengthminus);
  }
}

.pipes {
  width: 500px;
  height: 400px;
  position: relative;
}

.top,
.bottom {
  height: 10px;
  background-color: var(--color);
}

.bottom {
  position: absolute;
  bottom: 0;
  width: 100%;
}

.pipe {
  background-color: var(--bg);
  height: 10px;
  position: relative;
  overflow: hidden;
}

.pipe:after {
  content: "";
  display: block;
  position: absolute;
  background-color: var(--color);
  height: 10px;
  width: var(--flowlength);
  top: 0;
  left: 0;
}

.square {
  width: 200px;
  height: 200px;
  position: absolute;
  left: 50%;
  top: 50%;
  border-width: 10px;
  border-style: solid;
  border-color: var(--color);
  background-color: var(--bg);
  margin: -110px;
  0 0 -110px;
  z-index: 1;
}

.pipe:after {
  animation-duration: 2s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
  animation-name: flow;
}

.first {
  position: absolute;
  top: 10px;
  width: 100px;
  transform: rotate(90deg);
  transform-origin: 0 0;
}

.first.one {
  left: 50px;
}

.first.two {
  left: 50%;
}

.first.three {
  right: -50px;
}

.second:after {
  animation-delay: 0.6s;
}

.second.left {
  top: 100px;
  left: 40px;
  width: 100px;
  position: absolute;
}

.second.right {
  top: 100px;
  transform: scalex(-1);
  right: 50px;
  width: 100px;
  position: absolute;
}
<div class="pipes">

  <div class="top"></div>
  <div class="pipe first one"></div>
  <div class="pipe first two"></div>
  <div class="pipe first three"></div>

  <div class="pipe second left"></div>
  <div class="pipe second right"></div>

  <div class="square">content here</div>
</div>

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.