慕先生4328837
2021-04-13 10:07
<div style="width: 300px;height: 300px;background-color: rgba(47,41,90,0.14);position: relative;overflow: hidden;"> <div style="width: 300px;height: 300px;border: 40px dotted #36CBCB;box-sizing: border-box;position: relative;"> <div style="background-color: #36CBCB;width: 260px;height: 260px;position: absolute;top: -20px;left: -20px;"></div> </div> </div>
<div style="width: 300px;height: 300px;background-color: rgba(47,41,90,0.14);overflow: hidden;">
<div style="background-color: red;width: 260px;height: 40px;position: absolute;top: 0px;left: 20px;" ></div>
<div style="width: 300px;height: 300px;border: 40px dotted #36CBCB;box-sizing: border-box;position: relative;">
<div style="background-color: #36CBCB;width: 260px;height: 260px;position: absolute;top: -20px;left: -20px;"></div>
</div>
</div>
我是填充了一层红色来当边框的背景,也是通过定位来实现的,由于先写层级低于后面的边框层
CSS深入理解之border
56800 学习 · 73 问题
相似问题