3 回答

TA貢獻1864條經驗 獲得超6個贊
對此的另一種解決方案是使用CSS剪切路徑將三角形從彩色塊中剪切出來。不支持IE,但是可以用于內部工具等。
為方便起見,與SCSS一起編寫。
.outer {
background: orange;
width: 25%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 1em;
p {
margin: 0;
text-align: center;
color: #fff;
}
&:after {
content: '';
position: absolute;
top: 100%;
left: 0;
right: 0;
padding-bottom: 10%;
background: orange;
-webkit-clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
}
}

TA貢獻1813條經驗 獲得超2個贊
我找到了適用于任何寬度/高度的解決方案。您可以在linear-gradient背景中使用兩個偽元素,例如(fiddle):
.btn {
position: relative;
display: inline-block;
width: 100px;
height: 50px;
text-align: center;
color: white;
background: gray;
line-height: 50px;
text-decoration: none;
}
.btn:before {
content: "";
position: absolute;
top: 100%;
right: 0;
width: 50%;
height: 10px;
background: linear-gradient(to right bottom, gray 50%, transparent 50%)
}
.btn:after {
content: "";
position: absolute;
top: 100%;
left: 0;
width: 50%;
height: 10px;
background: linear-gradient(to left bottom, gray 50%, transparent 50%)
}
- 3 回答
- 0 關注
- 1203 瀏覽
相關問題推薦
添加回答
舉報