width: 0
height: 0
border-left: 50px solid transparent
border-right: 50px solid transparent
border-bottom: 100px solid red}
<divstyle=“height:300pxwidth:200pxborder:solide
1px
blue”></div>
关键是你的div要有一定的宽高。另外边框的颜色不要和背景色一样,这样也会看不出来
用css实现:
<style>.diamond{
display: inline-block
width: 14px
height: 14px
border: 2px solid blue
transform: rotate(45deg)
}
</style>
<div class="diamond"></div>
用svg实现:
<svg viewBox="0 0 100 100" width="20" height="20"><polygon points="10 50, 50 10, 90 50, 50 90" fill="none" stroke="blue" stroke-width="10" />
</svg>