2 回答

TA貢獻(xiàn)1719條經(jīng)驗(yàn) 獲得超6個(gè)贊
您只需使用 2 個(gè) div,其中的邊框和半徑為內(nèi)部 div。請(qǐng)參閱此處:
#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貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
如果你不想使用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>
添加回答
舉報(bào)