您可以在此处使用CSS pseudo元素绘制虚线:
.border {
border-top: 1px dotted #000000;
position: relative;
margin: 100px 0 0 0;
height: 4px;
}
.border::after {
content: "";
height: 1px;
border-top: 1px dotted #000000;
width: 100%;
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
.border::before {
content: "";
height: 1px;
border-top: 1px dotted #000000;
width: 100%;
position: absolute;
top: -4px;
left: 0;
right: 0;
}Run Code Online (Sandbox Code Playgroud)
<div class="border">
</div>Run Code Online (Sandbox Code Playgroud)