html - 如何使用 CSS 将一些水平偏移量添加到元素底部边框?

标签 html css

我在一些 a 元素上使用了 bottom-border,我想给边框添加一些水平偏移。

我现在拥有的:

Link very cool name
-------------------

我想要的:

Link very cool name
   ----------------

我该如何存档?仅使用 a 元素。

最佳答案

伪元素在这里是理想的选择,它可以按照您想要的任何方式设置样式,颜色、宽度和高度...甚至位于链接文本下方。

a {
  position: relative;
  text-decoration: none;
}
a::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  width: 75%;
  height: 2px;
  background: orange;
}
<a href="#">Long stretch of text</a>

关于html - 如何使用 CSS 将一些水平偏移量添加到元素底部边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35035766/

相关文章:

html - 在 Twitter bootstrap 3 中定位模态框

javascript - 使站点不出现在历史记录中(通过代码,而不是用户)

html - 从请求中选择输入值

javascript - 图像尺寸问题

javascript - 放大时如何将周围的元素推离屏幕?

html - "Dynamic"选择元素的背景

html - 在CSS中使绝对子div溢出其可滚动的相对根父级

jquery - 根据类别更改图像 src

html - 向左浮动打破布局

jquery - 使用 jquery hide() 函数时遇到问题?