Home > Web Front-end > CSS Tutorial > How Can I Create a Curved Div with a Transparent Top Using Clip Paths?

How Can I Create a Curved Div with a Transparent Top Using Clip Paths?

Susan Sarandon
Release: 2024-11-24 13:59:16
Original
1057 people have browsed it

How Can I Create a Curved Div with a Transparent Top Using Clip Paths?

Creating a Curved Div with a Transparent Top

In an attempt to design a transparent div spanning the entire width and with a height of approximately 500px, you have encountered challenges in achieving a curved shape. To obtain the desired shape, as illustrated in the provided image, utilize the following approach:

Using Clip Paths:

Implement clip paths on either the top or bottom elements and ensure they overlap as follows:

.first,
.second {
  display: inline-block;
  margin: 5px;
}

.first .top {
  clip-path: circle(72.9% at 50% 27%);
  height: 200px;
  width: 200px;
  background: url(https://picsum.photos/id/10/800/800) center/cover;
  position: relative;
}

.first .bottom {
  margin-top: -70px;
  background: yellow;
  height: 100px;
  width: 200px;
}

.second .top {
  height: 200px;
  width: 200px;
  background: url(https://picsum.photos/id/10/800/800) center/cover;
  position: relative;
}

.second .bottom {
  clip-path: polygon(0 25%, 14% 41%, 28% 51%, 49% 54%, 66% 53%, 79% 48%, 89% 39%, 100% 27%, 100% 100%, 47% 100%, 0% 100%);
  margin-top: -70px;
  background: yellow;
  height: 100px;
  width: 200px;
}
Copy after login
<div class="first">
  <div class="top">
  </div>
  <div class="bottom">
  </div>
</div>

<div class="second">
  <div class="top">
  </div>
  <div class="bottom">
  </div>
</div>
Copy after login

The above is the detailed content of How Can I Create a Curved Div with a Transparent Top Using Clip Paths?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template