我想要根據文字的寬度計算線條的寬度。這是我現在有:文字之後的線條寬度,取決於文字的寬度
h1 {
font-family: 'Roboto', sans-serif !important;
color: #de361b !important;
font-size: 25px;
margin-bottom: 20px !important;
font-weight: 700;
text-align:center;
}
h1:after {
content: ' ';
display: block;
height: 1px;
background-color: #de361b;
margin-top: 15px;
width: 60%;
margin-left: auto;
margin-right: auto;
}
<h1>Bierhalle Schepens heet u welkom!</h1>
<h1>Promoties van de maand</h1>
因此,大家可以看到,線的寬度不依賴於文本的寬度。這就是我想要的:
是否有一個簡單的方法來實現這一目標?
預先感謝您。
看起來像文本和線條具有相同的寬度,以我 – Filype
在屏幕截圖的第二行是更小的(取決於文本H1的lenght) – Jacob