如果利用border设置四周的border,如果一边的边框比较长无法对齐
解决办法:
.test{ position: relative; border: 1px solid #808080; height: 100px; width: 100px; } .test:after{ content: ''; position: absolute; right: -10px; top:-1px; width: 0; height: 0; border-width: 102px 10px 0 0; border-style: solid; border-color:red; } <div class="test"> </div>