這個問題在這里已經有了答案:
#foo {
height: 100px;
width: 100px;
background-color: red;
border-top: 10px solid blue;
}
<div id="foo"></div>
uj5u.com熱心網友回復:
您可以嘗試使用 ::before 和 ::after
#foo {
height: 100px;
width: 100px;
background-color: red;
}
#foo::before {
border-top: 5px solid blue;
width: 80px;
height: 5px;
position: absolute;
content: '';
margin-left: calc((100px - 80px)/2);
top: 3px;
}
<div id="foo"></div>
uj5u.com熱心網友回復:
這樣的事情應該可以解決問題:)
受到您發布的鏈接上未接受的答案之一的啟發
#foo {
position: relative;
height: 100px;
width: 100px;
background-color: red;
}
#foo:after {
content: "";
position: absolute;
background-color: blue;
width: 80%;
left: 10%;
height: 10px;
top: -10px;
}
<div id="foo"></div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/375077.html
上一篇:如何在頁面加載時觸發Javascript輪播的自動播放?
下一篇:如何使用標簽制作自定義收音機輸入
