<div id="description">
  <h2>Приклад 1: зміна елемента за допомогою cross-fade()</h2>
  <p>Наведіть курсор на елемент, щоб побачити зміну.</p>
</div>

<div id="result">
  <div class="image-container">
    <div class="image crossfade"></div>
  </div>
</div>
#description {
  background-color: #f2f2f2;
  padding: 20px;
  font-family: Arial, sans-serif;
}

#result {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 400px;
}

.image-container {
  position: relative;
}

.image {
  width: 300px;
  height: 300px;
  background-size: cover;
  background-position: center;
}

.crossfade {
  background-image: -webkit-cross-fade(url("https://picsum.photos/200/200"), url("https://picsum.photos/250/250"), 50%);
  background-image: cross-fade(url("https://picsum.photos/200/200"), url("https://picsum.photos/250/250"), 50%);
  transition: background-image 0.3s ease;
}

.crossfade:hover {
  background-image: -webkit-cross-fade(url("https://picsum.photos/200/200"), url("https://picsum.photos/250/250"), 0%);
  background-image: cross-fade(url("https://picsum.photos/200/200"), url("https://picsum.photos/250/250"), 0%);
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.