步骤
- 设置一个盒子
- 设置四周不同颜色的边框
- 将盒子宽高设置为0,仅保留边框
- 得到四个三角形,选择其中一个后其他三角形(边框设置颜色为透明)
- 将上边框设置为0(去除隐藏部分占据的高度)
代码代码实现
<style>
.box{
/* width: 300px;
height: 300px; */
/* background-color: pink; */
width:0;
height:0;
border-top:0px solid transparent;
border-bottom:50px solid solid green;
border-left:50px solid transparent;
border-right:50px solid transparent;
}
</style>