我喜欢一个听话的frotend开发人员必须使用2px填充而不是1px默认创建下划线.存在简单的解决方案吗?
PS Yeahh伙计们,我知道div有黑色背景颜色和1px*Npx和位置:相对,但它太慢了......
Jas*_*aro 33
你可以自动换行的span
,并给它一个border-bottom
用padding-bottom:2px;
.
像这样
span{
display:inline-block;
border-bottom:1px solid black;
padding-bottom:2px;
}
Run Code Online (Sandbox Code Playgroud)
Rus*_*kin 15
对于跨浏览最好是使用text-underline-offset
过的text-underline-position
,因为text-underline-position
不支持iOS的Safari浏览器
所以使用这个答案:https : //stackoverflow.com/a/63607426/1894907
#line{
text-decoration-line: underline;
text-underline-offset: 2px;
}
Run Code Online (Sandbox Code Playgroud)
小智 11
在没有添加额外跨度和更多控制的情况下执行此操作的好方法是使用:after
选择器.
特别适用于导航菜单:
.active a:after {
content: '';
height: 1px;
background: black;
display:block;
}
Run Code Online (Sandbox Code Playgroud)
如果您希望文本和下划线之间有更多或更少的空间,请添加一个margin-top
.
如果您想要更粗的下划线,请添加更多height
:
.active a:after {
content: '';
height: 2px;
background: black;
display:block;
margin-top: 2px;
}
Run Code Online (Sandbox Code Playgroud)
小智 10
只需使用:
text-decoration: underline;
text-underline-position: under;
Run Code Online (Sandbox Code Playgroud)
小智 6
#line{
text-decoration-line: underline;
text-underline-offset: 1px;
}
Run Code Online (Sandbox Code Playgroud)
<div id="line">
Text with line
</div>
Run Code Online (Sandbox Code Playgroud)
只是使用
{
text-decoration-line: underline;
text-underline-offset: 2px;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
64205 次 |
最近记录: |