創建一個頂部透明的彎曲Div
嘗試設計一個橫跨整個寬度且高度約為500px,您在實現彎曲形狀時遇到了挑戰。要獲得所需的形狀,如所提供的圖像所示,請使用以下方法:
使用剪輯路徑:
在頂部或底部元素上實現剪輯路徑並確保它們重疊如下:
.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>
以上是如何使用剪輯路徑創建頂部透明的彎曲 Div?的詳細內容。更多資訊請關注PHP中文網其他相關文章!