html - 对象之间的文本装饰空间

标签 html css underline

如何在边框之间留出空间(underline 悬停效果)。并且线条的颜色应该是红色。

a {
  text-decoration: none
}

li {
  display: inline;
}

li:hover {
  text-decoration: underline;
}
<li><a href="">
  abc
</a></li>
<li><a href="">
  def
</a></li>
<li><a href="">
  ggg
</a></li>
<li><a href="">
  hello
</a></li>

最佳答案

改用border-bottompadding

a {
  text-decoration: none
}
li {
  display: inline-block;
}
li:hover {
  border-bottom: 1px solid red;
  padding-bottom: 10px;
}
<li><a href="">
  abc
</a>
</li>
<li><a href="">
  def
</a>
</li>
<li><a href="">
  ggg
</a>
</li>
<li><a href="">
  hello
</a>
</li>

关于html - 对象之间的文本装饰空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37722854/

相关文章:

html - CSS 显示表宽度 100% - 缺少像素?

javascript - 更改 `setInterval` 内元素的背景颜色

html - 下拉导航链接不起作用

html - CSS:为大下行字体制作厚 <a:hover> 下划线的正确方法

javascript - 如何在一个 Vuejs 元素中使用多个模板?

html - 标题 Logo 图像可以溢出 955px 的正常内容宽度吗?

下拉选择器的CSS

javascript - 如何消除两个 jQuery 插件之间的冲突?

ios - iphone notes.app 喜欢下划线

java - 在 Android 中使用 SpannableString 在 TextView 中虚线下划线