html - 我如何使用 hr 获取他父 div 的全宽?

标签 html css

我有这段代码,我正在尝试让 hr 在文本开始时开始,在文本结束时结束,这可能吗?实际上它只需要初始宽度屏幕

.slider-single {
  white-space: nowrap !important;
  overflow-x: auto;
  overflow-y: hidden;
}

a {
  text-decoration: none;
  color: red;
  font-weight: 800;
  margin-left: 3rem;
}

hr {
  background-color: blue;
}
<div class="slider-single">
  <div>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
  </div>
  <hr>
</div>

最佳答案

将内部 div 设为 inline-block 并为其添加 border-bottom

.slider-single {
  white-space: nowrap !important;
  overflow-x: auto;
  overflow-y: hidden;
}
.slider-single > div {
  display:inline-block;
  padding-bottom:10px;
  border-bottom:1px solid blue;
  margin-bottom:10px;
  margin-left: 3rem;
}
a {
  text-decoration: none;
  color: red;
  font-weight: 800;
}
a:not(:first-child) {
  margin-left: 3rem;
}
<div class="slider-single">
  <div>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
    <a href="#info">Test</a>
  </div>
</div>

关于html - 我如何使用 hr 获取他父 div 的全宽?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57109658/

相关文章:

jquery - 在没有滚动条的全屏页面上具有视差效果的图像

javascript - 当我添加另一个 div 时,文本不显示

javascript - jQuery 正则表达式选择器插件不工作

html - 使用自己的 CDN 嵌入的 CSS 字体不起作用

css - Ionic 2 如何使 ionic 列表从下往上增长?

html - CSS 将一张图片放在另一张图片之上

html - 使用 css 在 div 下对齐标记

html - 如何更改 Franklin.jl 中的相对路径?

javascript - html元素内存存储容量值

html - 带有汉堡菜单的 Bootstrap 下拉菜单