PHP中文网2017-04-17 14:48:43
一般使用絕對定位來解決
<p class="parent">
<span class="text">推荐</span>
<p class="triangle-topleft">
</p>
</p>
.parent{
position: relative;
width: 200px;
height: 200px;
}
.parent .text{
display: inline-block;
transform: rotate(-45deg);
padding: 20px;
color: #fff;
}
.triangle-topleft{
width: 0;
height: 0;
border-top: 100px solid red;
border-right: 100px solid transparent;
position: absolute;
top: 0;
z-index: -1;
}