4 653 Layout / Codepen

Эффект разорванных фотографий

Эффект разорванных изображений реализованный с помощью svg фильтров с разными настройками.


HTML

<div class="container">
  <div class="card">
    <div class="image image1"></div>
    <div class="info">
      <h2>About me</h2>
      <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Possimus libero voluptatum sit! Sequi facere in tempora quibusdam mollitia provident aut?</p>
    </div>
  </div>
  <div class="card">
    <div class="image image2"></div>
  </div>
  <div class="card">
    <div class="image image3"></div>
  </div>
</div>
<svg>
  <filter id="wavy1">
    <feturbulence x="0" y="0" baseFrequency="0.2" numOctaves="5" seed="1"></feturbulence>
    <feDisplacementMap in="SourceGraphic" scale="20" />
  </filter>
</svg>
<svg>
  <filter id="wavy2">
    <feturbulence x="0" y="0" baseFrequency="0.02" numOctaves="5" seed="1"></feturbulence>
    <feDisplacementMap in="SourceGraphic" scale="20" />
  </filter>
</svg>
<svg>
  <filter id="wavy3">
    <feturbulence x="0" y="0" baseFrequency="0.1" numOctaves="5" seed="1"></feturbulence>
    <feDisplacementMap in="SourceGraphic" scale="20" />
  </filter>
</svg>

CSS

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #f4f4f4;
  padding: 20px;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.container .card {
  position: relative;
  width: 280px;
  height: 350px;
  margin: 30px;
}

.container .card:nth-of-type(2) {
  transform: rotate(5deg);
}

.container .card .image {
  position: relative;
  width: 100%;
  height: 100%;
  background-size: cover;
  transform: translate(10px, 10px);
}

.container .card:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 255px;
  height: 325px;
  border: 25px solid #fff;
  z-index: 1;
  background: linear-gradient(145deg, #ffffff, #e6e6e6);
  box-shadow: 7px 7px 21px #bdbdbd, -7px -7px 21px #ffffff;
  background: transparent;
}

.container .card:nth-of-type(1)::before {
  filter: url(#wavy1);
}

.container .card:nth-of-type(2)::before {
  filter: url(#wavy2);
}

.container .card:nth-of-type(3)::before {
  filter: url(#wavy3);
}

.image1 {
  background-image: url("https://res.cloudinary.com/dswp5qfpm/image/upload/v1597476074/animal/rabbit_vq9gli.jpg");
}

.image2 {
  background-image: url("https://res.cloudinary.com/dswp5qfpm/image/upload/v1597476033/animal/cat_hfwcwm.jpg");
}

.image3 {
  background-image: url("https://res.cloudinary.com/dswp5qfpm/image/upload/v1597476068/animal/parrot_rjd1vq.jpg");
}

svg {
  width: 0;
  height: 0;
}

.container .card .info {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 50px 30px 30px 30px;
  transform: translate(10px, 10px);
  text-align: center;
  background-color: rgba(0, 0, 0, 0.5);
  color: #fff;
  line-height: 1.4;
  font-size: 20px;
  opacity: 0;
  transition-duration: 1s;
}

.container .card:hover .info {
  opacity: 1;
}

Комментарии

  • Facebook
  • Вконтакте

Похожие статьи