你如何在 CSS 中的 div 底部實作這種東西?

我試試
&:before {
content: '';
position: absolute;
z-index: 2;
width: 133.93px;
height: 93.63px;
border-radius: 5px;
border: 1px solid #ffffff;
box-shadow: 1px 1px 0 rgba(0,0,0,0.2);
background-image: $gradeint;
text-align: center;
transform-origin: center;
transform: rotateZ(45deg);
top: -10%;
right: 0;
}
但這不是我想要的
uj5u.com熱心網友回復:
您可以使用該clip-path屬性實作類似形狀的功能。這是一個例子。
紫色區域實際上涵蓋了整個容器,但clip-path它是剪輯到由點定義的多邊形組0 0, 100% 0, 35% 60%, 0 0,其中0, 0是容器的左上角和100%, 100%將是右下角。
.container {
width: 300px;
height: 200px;
border: 1px solid black;
position: relative;
display: flex;
}
.accent {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
background-color: purple;
clip-path: polygon(0 0, 100% 0, 35% 60%, 0 0);
}
.image {
width: 125px;
height: 125px;
background-color: lightgray;
border-radius: 125px;
margin: auto;
z-index: 1;
}
<div class="container">
<div class="accent"></div>
<div class="image"></div>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/328512.html
標籤:css
上一篇:文字和圖片并排
