您可以使用伪元素,例如::before或::after使用transformcss属性创建倾斜图层并使用绘制背景图像linear-gradient().
.shape {
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
z-index:0;
margin: 0 auto;
color: #fff;
display: flex;
height: 80vh;
width: 80vh;
}
.shape::before {
background: linear-gradient(to top right, maroon 50%, red 50%);
transform: skewX(-20deg);
position: absolute;
z-index: -1;
content: '';
bottom: 0;
right: 0;
left: 0;
top: 0;
}Run Code Online (Sandbox Code Playgroud)
<div class="shape">Content Goes Here...</div>Run Code Online (Sandbox Code Playgroud)
参考文献:
| 归档时间: |
|
| 查看次数: |
50 次 |
| 最近记录: |