html - 对齐文本和线平行

标签 html css

enter image description here

有 4 个 div,其中包含文本和一行。文本将来自服务电话,可能会有所不同。问题是线没有正确显示它的长度不同。主要条件是 1)所有的线都应该在同一点结束。 2)线应该是 30px 从边距和 3)文字与线条的间距应为12px。

.about{
    display: inline-block;
}
hr{
  display:inline-block;
  width:200px;
}
<div>

<div class="about">Chapter</div><hr/></div>
<div>
<div class="about">Learning Objectives</div><hr/></div>
<div>
<div class="about">Pages</div><hr/></div>
<div>
<div class="about">Sections</div><hr/></div>

我尝试了 min,max-width 但找不到解决方案。谁能提供更好的解决方案?

最佳答案

试试这个。

.about {
  float: left;  
}
hr {
  width: auto;
  margin-left: 30px;
}
.test {
  overflow: hidden;
}
<div class="test">
  <div class="about">Chapter</div>
  <hr/>
</div>
<div class="test">
  <div class="about">Learning Objectives</div>
  <hr/>
</div>
<div class="test">
  <div class="about">Pages</div>
  <hr/>
</div>
<div class="test">
  <div class="about">hhhhhhhhhhhhhhh</div>
  <hr/>
</div>

关于html - 对齐文本和线平行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47322047/

相关文章:

javascript - 如何在 Angular Material 表中获取 <tr> 之间的间隙

css - 防止正文滚动但允许覆盖滚动

javascript - 将鼠标悬停在 id 上时会更改图像

javascript - 使用 Javascript 动态删除行。我的代码有什么问题?

javascript - DOMDocument 去除 JavaScript 字符串中的 HTML 标签

html - 删除输入框

jquery - 100% Div 居中,固定宽度的内部 Div

javascript - 将鼠标悬停在 div 上时无法调整输入

javascript - 语法错误: unterminated string literal

html - 从 HTML 电子邮件 iPhone 中删除日期/时间样式