参考页面:https://blog.youkuaiyun.com/weixin_52208686/article/details/127863330
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
margin: 20px auto;
}
.card3 {
background-image: linear-gradient(to right, #000 35%, rgba(255, 255, 255, 0) 0%);
/* 35%设置虚线点x轴上的长度 */
background-position: bottom;
/* top配置上边框位置的虚线 */
background-size: 20px 5px;
/* 第一个参数设置虚线点的间距;第二个参数设置虚线点y轴上的长度 */
background-repeat: repeat-x;
}
.card4 {
height: 40px;
background-image: linear-gradient(rgb(51, 89, 228) 35%, rgba(255, 255, 255, 0) 0%);
/* 35%设置虚线点y轴上的长度 */
/* background-position: left; right配置右边框位置的虚线 */
background-size: 7px 10px;
/* 第一个参数设置虚线点x轴上的长度;第二个参数设置虚线点的间距 */
background-repeat: repeat-y;
}
.card5 {
border: 6px dashed transparent;
background: linear-gradient(#fff, #fff) padding-box,
repeating-linear-gradient(-45deg, #000 0, #000 0.3em, #fff 0, #fff 0.6em);
/* 0.3em设置虚线点的宽度或长度;0.6em设置虚线点的间距 */
}
.card6 {
height: 10px;
background-image: repeating-linear-gradient(90deg, #1046f1 0, #1046f1 20px, #9cacdf 20px, #9cacdf 40px);
}
</style>
</head>
<body>
<div class="box card3">
</div>
<div class="box card4">
</div>
<div class="box card5">
</div>
<div class=" box card6">
</div>
</body>
</html>