1

Уважаемые коллеги, как можно реализовать прелоадер в виде серых треугольников поверх текста при загрузке страницы?

введите сюда описание изображения

1
  • Нет, в принципе, как все это реализовать 30 июн 2021 в 12:24

2 ответа 2

8

Вариантов много, можно нагуглить на любой вкус.
Ниже сделал вам пример с таймеров в 3 секунды.

setTimeout(() => {
  document.querySelectorAll('.bg').forEach((elBg) => elBg.classList.remove('bg'));
}, 3000);
.container {
  position: relative;
  overflow: hidden;
  display: grid;
  max-width: 550px;
  grid-template-columns: 200px 1fr;
  grid-template-rows: repeat(2, 1fr);
  grid-column-gap: 10px;
  grid-row-gap: 10px;
}

.container>p {
  margin: 0;
}

.img {
  grid-area: 1 / 1 / 3 / 2;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 0 auto;
  object-fit: cover;
  overflow: hidden;
}

.img>img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.p1 {
  grid-area: 1 / 2 / 2 / 3;
}

.p2 {
  grid-area: 2 / 2 / 3 / 3;
}

.bg {
  position: relative;
  overflow: hidden;
}

.bg:before,
.bg:after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.bg:before {
  background: #f9f9f9;
}

.bg:after {
  display: block;
  width: 150px;
  background: linear-gradient(to right, transparent 0%, #E8E8E8 50%, transparent 100%);
  animation: load 1s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
}

@keyframes load {
  from {
    left: -150px;
  }
  to {
    left: 100%;
  }
}
<div class="container">
  <div class="img bg">
    <img src="https://images.unsplash.com/photo-1624994914384-4c87c00e1981?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=3150&q=80">
  </div>
  <p class="p1 bg">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  <p class="p2 bg">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled</p>
</div>

0

Самый простой вариант - делаешь фоновую картинку в виде этих заглушек, а сам контент кладешь в блок с одноцветной заливкой (например, белой) и, когда он появляется, заглушки просто будут скрыты

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