css - 在 IE11 中,flexbox div 不尊重容器,文本在一行中溢出,而不是换行

标签 css internet-explorer flexbox

<分区>

我下面的代码在 Chrome/Firefox 中正常工作,但在 IE11 中,卡片 flexbox div 不尊重容器,文本溢出,在一行中,而不是换行

.container {
    display: -ms-flexbox;
    display: flex;
    -ms-flex-pack: start;
    -ms-flex-direction: row;
    flex-direction: row;
    margin: 3rem auto 0;
    -ms-flex-positive: 1;
    flex-grow: 1;
    margin-right: auto;
    margin-left: auto;
    max-width: 20.25rem;
    border: 1px solid red;
}

.left {
  flex: 1 1 auto;
}

.card {
  display:flex;
  align-items:stretch;
  justify-content:flex-start;
  border: 1px solid black;
}



.card-image{
  align-self:center;
  width: 5rem;
}

.card-image img {
 max-width: 100%;
}

.card-content {
 padding:1rem;
}

.right {
  display:flex;
  flex: 0 0 4.75rem;
  align-items: flex-end;
  flex-flow: column nowrap;
}
<div class="container">
  <div class="left">
    <div class="card">
      <div class="card-image">
        <img src="https://via.placeholder.com/100x100">
      </div>
      <div class="card-content">
      <h2>Lorem Technology Corporation</h2>
       <p class="card-text">
       book. It has survived not only five centuries, but also the  leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
</p>
</div>
</div>
</div>                                
                           
<div class="right">
  <img src="https://via.placeholder.com/50x600">
</div>
</div>
enter image description here

最佳答案

width: 100%; 添加到包装器。在此示例中,.left

.container {
    display: -ms-flexbox;
    display: flex;
    -ms-flex-pack: start;
    -ms-flex-direction: row;
    flex-direction: row;
    margin: 3rem auto 0;
    -ms-flex-positive: 1;
    flex-grow: 1;
    margin-right: auto;
    margin-left: auto;
    max-width: 20.25rem;
    border: 1px solid red;
}

.left {
  flex: 1 1 auto;
  width: 100%; /* IE Fix */
}

.card {
  display:flex;
  align-items:stretch;
  justify-content:flex-start;
  border: 1px solid black;
}



.card-image{
  align-self:center;
  width: 5rem;
}

.card-image img {
 max-width: 100%;
}

.card-content {
 padding:1rem;
}

.right {
  display:flex;
  flex: 0 0 4.75rem;
  align-items: flex-end;
  flex-flow: column nowrap;
}
<div class="container">
  <div class="left">
    <div class="card">
      <div class="card-image">
        <img src="https://via.placeholder.com/100x100">
      </div>
      <div class="card-content">
      <h2>Lorem Technology Corporation</h2>
       <p class="card-text">
       book. It has survived not only five centuries, but also the  leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
</p>
</div>
</div>
</div>                                
                           
<div class="right">
  <img src="https://via.placeholder.com/50x600">
</div>
</div>

Working fiddle

关于css - 在 IE11 中,flexbox div 不尊重容器,文本在一行中溢出,而不是换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54822591/

上一篇:css - 向右浮动列表组

下一篇:html - 背景图像未显示在 div 中

相关文章:

html - 通过与外部类名相关的 CSS 设置内联 SVG 填充颜色

jquery - fabric.js 显示 Canvas 文本的镜像

javascript - 像 http ://vimeo. com/这样的导航菜单

javascript - 在什么情况下Javascript在IE8中的性能会比IE7差?

jQuery fadeIn 在 IE7 中留下未消除锯齿的文本

html - Flash 播放器上的下拉菜单

html - 为什么这个 div 在有足够空间的情况下不与其他 div 内联?

html - 使用 align-self 将 flex 子节点放置在彼此旁边

html - 具有方形比例和 flexbox 的内部 div

css - flex-wrap wrap时flex-shrink有什么用吗?