答案 0 :(得分:6)
您可以在此处使用 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;
}
<div class="border">
</div>
答案 1 :(得分:2)
重复渐变可以做到
div {
height: 1.5em;
background-image: radial-gradient(grey 15%, transparent 16%), radial-gradient(grey 15%, transparent 16%);
background-size: .5em .5em;
background-position: 0 0, .5em .5em
}
&#13;
<div></div>
&#13;