css - 仅样式下划线

标签 css underline

我有一个使用 text-decoration: underline; 加下划线的标题,唯一的问题是线条太细了。我只想使下划线变粗。我考虑过使用 border-bottom 来执行此操作,但边框会拉伸(stretch)容器的整个宽度并且文本居中。不起作用。

最佳答案

您可以用 <span> 包裹文本周围的标签,使用 display: inline-block; , 删除 text-decoration: underline;属性并添加 border-bottom: 2px solid #000;

Demo

Note: Why use inline-block? So that you can also control the spacing between the border and the text, using padding or margins, but if you don't require display: 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 particular span tag of a particular element.class pair.

关于css - 仅样式下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17417668/

相关文章:

javascript - 在搜索栏下拉选项之间添加空格

html - 如何停止幻灯片在滚动条上移动

javascript - Bxslider 从寻呼机中删除点并将它们替换为数字,例如 4 中的 1 和 next-prev 链接

css - 修复损坏的 <a> 具有多个跨度的装饰

CSS 下划线和字母间距

C# Winforms DataGridViewLinkColumn 动态删除下划线

javascript - 在 Ruby on Rails 中包含 Trianglify

html - 将 div 置于图像之上

css 下划线过渡悬停状态弹跳我的列表项

ios - 在 UITextField 下放置一行的正确方法是什么