我有一个使用 text-decoration: underline;
加下划线的标题,唯一的问题是线条太细了。我只想使下划线变粗。我考虑过使用 border-bottom
来执行此操作,但边框会拉伸(stretch)容器的整个宽度并且文本居中。不起作用。
最佳答案
您可以用 <span>
包裹文本周围的标签,使用 display: inline-block;
, 删除 text-decoration: underline;
属性并添加 border-bottom: 2px solid #000;
Note: Why use
inline-block
? So that you can also control the spacing between theborder
and the text, usingpadding
ormargins
, but if you don't requiredisplay: inline-block;
you can simply get rid of it as NullPoiиteя said. Also, be sure to use a class on the parent element to select particularspan
tag of a particularelement.class
pair.
关于css - 仅样式下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17417668/