This question already has answers here:
Draw line after a title with CSS [duplicate]
                                
                                    (3个答案)
                                
                        
                                2年前关闭。
            
                    
我想获得下图中的标头css - 在标题附近放置“线”,与标题大小,长度,填充或边距无关-LMLPHP

我可以使用绝对位置来获得,但这取决于标题的特征,例如margin,padding。

我感兴趣的是下面的结果,不管标题大小,长度,填充或边距。我需要IE10,IE11等旧版浏览器也支持的功能。

最佳答案

使用:after并在该行中创建
学习:https://developer.mozilla.org/en-US/docs/Web/CSS/::after



div{
color:red;
}
div:after{
    content: "";
    position: absolute;
    width: 100%;
    height: 1px;
    background-color: red;
    top: 20px;
    margin-left: 10px;
    margin-right: 4px;
}

<div>Header</div>

关于css - 在标题附近放置“线”,与标题大小,长度,填充或边距无关,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51017221/

10-12 12:18
查看更多