使用border-image property可以更快地实现这一点.坐square image shape路车,把它放在div的边框里.上面所附的链接有一个相关的例子.请看一看.
OR个
你可以试试这个不需要图像的:-
.container{
display: flex;
}
.container > .box{
padding: 2rem 1rem;
border: 1px solid black;
position: relative;
}
.container > .box:nth-child(odd):before,
.container > .box:after
{
content: '';
display: block;
width: 10px;
height: 10px;
border: 1px solid black;
background-color: pink;
position: absolute;
z-index: 1;
}
.container > .box:before{
top: -5px;
left: -5px;
}
.container > .box:after{
top: -5px;
right: -5px;
}
.container > .box:nth-child(odd) > span:before,
.container > .box > span:after
{
content: '';
display: block;
width: 10px;
height: 10px;
border: 1px solid black;
background-color: pink;
position: absolute;
z-index: 1;
}
.container > .box > span:before{
bottom: -5px;
left: -5px;
}
.container > .box > span:after{
bottom: -5px;
right: -5px;
}
<div class="container">
<div class="box">
<span>Lorem Ipsum</span>
</div>
<div class="box">
<span>Ipsum Lorem</span>
</div>
</div>