【问题标题】:img inside d-flex div causes image to overflow in Bootstrap 4 in IE 11d-flex div 中的 img 导致图像在 IE 11 的 Bootstrap 4 中溢出
【发布时间】:2018-06-16 00:54:07
【问题描述】:

我有一个带有 bootstrap 4 网格系统的页面,它在除 IE 11 之外的所有浏览器上都能正常呈现。我在 jsfiddle 上有这个 snippet,您可以在 IE 11 中查看它以查看图像在 d-flex 内被拉伸容器。我该如何解决这个问题?

<div class="container-fluid">
  <div class="row py-3 justify-content-center">
    <div class="col-3 bg-primary">
      This content is longer than image This content is longer than image This content is longer than image This content is longer than image This content is longer than image This content is longer than image
    </div>
    <div class="col-5 d-flex align-items-center">
      <img class="img-fluid" src="https://www.w3schools.com/w3css/img_lights.jpg">
    </div>
    <div class="col-3 bg-primary">
      This content is longer than image This content is longer than image This content is longer than image This content is longer than image This content is longer than image This content is longer than image
    </div>
  </div>
</div>

【问题讨论】:

    标签: html css flexbox bootstrap-4


    【解决方案1】:

    网格系统允许整个页面有 12 列,所以试试这个

    <div class="container-fluid">
      <div class="row py-3 justify-content-center">
        <div class="col-3 bg-primary">
          This content is longer than image This content is longer than image This content is longer than image This content is longer than image This content is longer than image This content is longer than image
        </div>
        <div class="col-6 d-flex align-items-center">
          <img style=height:100%;width: 100%; src="https://www.w3schools.com/w3css/img_lights.jpg">
        </div>
        <div class="col-3 bg-primary">
          This content is longer than image This content is longer than image This content is longer than image This content is longer than image This content is longer than image This content is longer than image
        </div>
      </div>
    </div>
    

    【讨论】:

    • justify-content-center 那就没有意义了,我特意留了个空格
    • 我无法理解您希望图像等距还是?你能提供更多关于你想做什么的信息吗
    • 你在 IE 11 上测试过这个吗?它在 IE 10 上运行良好,但在 11 中它会导致图像拉伸,如果您在任何其他浏览器中看到,您会看到图像不仅垂直居中而且包含未拉伸。我想在 IE11 中达到同样的效果
    • w3schools.com/w3css/img_lights.jpg">添加这个怎么样
    • 我会检查,但如果我不必内联会更好!
    猜你喜欢
    • 2021-01-01
    • 2017-12-16
    • 1970-01-01
    • 2019-01-06
    • 1970-01-01
    • 2021-07-21
    • 2019-08-17
    • 2019-04-12
    • 1970-01-01
    相关资源
    最近更新 更多