2 回答

TA贡献1719条经验 获得超6个赞
您只需使用 2 个 div,其中的边框和半径为内部 div。请参阅此处:
#inside {
border: 5px solid grey;
padding: 10px;
border-radius: 25px;
height: 200px;
background: grey;
}
#outside {
border: 5px solid grey;
padding: 10px;
background: black;
}
<div id="outside">
<div id="inside">
</div>
</div>

TA贡献1865条经验 获得超7个赞
如果你不想使用2 DOM使用伪元素:之前
body{
padding: 15px;
}
div{
height:120px;
width:150px;
background-color:black;
border-radius:20px;
position:relative;
}
div:before{
content: '';
position: absolute;
height: 126%;
width: 120%;
background-color: red;
z-index: -1;
position: absolute;
top: -13%;
left: -10%;
}
<div></div>
添加回答
举报