html - 一个 hr 元素位于另一个全尺寸元素旁边(bootstrap 3.3.7)

标签 html css twitter-bootstrap

我想要<hr>我的图标旁边的元素,我将显示样式设置为 .inline-grid让 hr 元素保留在我的图标旁边。 问题是我需要给它一个宽度,因为内联网格需要它的全尺寸宽度。

hr 元素怎样才能是全尺寸并且仍然位于图标之间?

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 
    <div class="container">
      <div class="row">
        <span style="cursor: pointer">
          <span class="glyphicon glyphicon-chevron-down"></span>
          <hr style="width: 100px;margin-left: 0px;margin-right: 0px;display: inline-grid;margin-bottom: 0px;"/>
          <span class="glyphicon glyphicon-chevron-down"></span>
        </span>
      </div>
    </div>


编辑:<hr>元素应该仍然是水平的。 (图标水平线图标)<=这应该占据完整的行宽度。

Edit2:截图中的 Bootstrap 版本错误。更改为3.3.7。

最佳答案

使用显示 Flex 来代替显示内联网格。

hr {
  flex:1;
}

.wrapper {
  cursor: pointer;
  width: 100%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <div class="row">
    <div class="wrapper d-flex justify-content-center align-items-center">
      <span class="glyphicon glyphicon-chevron-down">V</span>
      <hr/>
      <span class="glyphicon glyphicon-chevron-down">V</span>
    </div>
  </div>
</div>

关于html - 一个 hr 元素位于另一个全尺寸元素旁边(bootstrap 3.3.7),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58409942/

相关文章:

javascript - 滑出菜单退出标志移动

php - 按窗口高度的比例更改多个 div 的高度

html - 是否可以使用 CSS 在模糊度之上添加文本

twitter-bootstrap - 下拉菜单在移动设备上不起作用

html - 垂直对齐 Div 中的文本

html - 页面周围出现异常 "border"

javascript - 复制表格的一部分

css - 如何在我的文本之后创建一条与容器宽度相同的线?

html - 对 Bootstrap 行使用 Flexbox 顺序

javascript - 如何以编程方式滚动 Bootstrap 下拉菜单