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; }
<div class="first"> <div class="top"> </div> <div class="bottom"> </div> </div> <div class="second"> <div class="top"> </div> <div class="bottom"> </div> </div>
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!