在ie11中使用flexbox在图像下方的间隙

时间:2016-10-21 12:34:52

标签: css css3 flexbox

所以我试图仅使用display:flex(尝试学习flex的所有细微差别)来回答this question但是我遇到了一个问题,即ie11,下面似乎有一个空格图像 - 看起来好像图像持有者正在拍摄原始图像的高度。

是否有一个简单的解决方案,以便图像保持器与其内部的图像一样高?

body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
}

body {
  display: flex;
  max-height: 100%;
}

.wrapper {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  height: 100%;
  max-height: 100%;
  width: 100%;
  overflow: hidden;
}

header {
  background: grey
}

main {
  display: flex;
  flex-direction: row;
  flex: 1;
  background: blue
}

.column {
  width: 50%;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.column:first-child {
  background: yellow;
}

.column:last-child {
  background: green;
}

.image-holder {
  margin-bottom: 10px;
  background: orange;
}

.image {
  width: 100%;
  display: block;
  height: auto;
}

.scrollable-content {
  flex: 1;
  background: grey;
  position: relative;
  height: 10px;
}

.firefox-scroller {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  overflow: auto;
  padding: 20px;
  box-sizing:border-box;
}
<div class="wrapper">
  <header>header</header>
  <main>
    <div class="column">
      <div class="image-holder">
        <img src="http://l7.alamy.com/zooms/19704c162b4446c984a50bfdb49b45ac/a-colour-image-taken-on-a-cloudy-dawn-of-the-town-of-saint-malo-from-g1k27a.jpg" alt="" class="image">
      </div>
      <div class="scrollable-content">
        <div class="firefox-scroller">
          <h1>I am trying to do:</h1>
          <h3>1) make these gray div height 100% till bottom</h3>
          <h3>2) When content is more then this gray div should be scrollable or else not</h3>
          <p>
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
          </p>

        </div>
      </div>
    </div>
    <div class="column">
      <div class="image-holder">
        <img src="http://l7.alamy.com/zooms/19704c162b4446c984a50bfdb49b45ac/a-colour-image-taken-on-a-cloudy-dawn-of-the-town-of-saint-malo-from-g1k27a.jpg" alt="" class="image">
      </div>

    </div>
  </main>
</div>

我尝试过使用flex-shrink和flex-basis,但似乎无法摆脱那个空间。愚蠢的!

1 个答案:

答案 0 :(得分:1)

您可以使用min-height强制重排IE:

示例:

&#13;
&#13;
body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
}
body {
  display: flex;
  max-height: 100%;
}
.wrapper {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  height: 100%;
  max-height: 100%;
  width: 100%;
  overflow: hidden;
}
header {
  background: grey
}
main {
  display: flex;
  flex-direction: row;
  flex: 1;
  background: blue
}
.column {
  width: 50%;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  flex: 1;
  flex-direction: column;
}
.column:first-child {
  background: yellow;
}
.column:last-child {
  background: green;
}
.image-holder {
  margin-bottom: 10px;
  background: orange;
  min-height: 1%;
  /* added for IE */
}
.image {
  width: 100%;
  display: block;
  height: auto;
}
.scrollable-content {
  flex: 1;
  background: grey;
  position: relative;
  height: 10px;
}
.firefox-scroller {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  overflow: auto;
  padding: 20px;
  box-sizing: border-box;
}
&#13;
<div class="wrapper">
  <header>header</header>
  <main>
    <div class="column">
      <div class="image-holder">
        <img src="http://l7.alamy.com/zooms/19704c162b4446c984a50bfdb49b45ac/a-colour-image-taken-on-a-cloudy-dawn-of-the-town-of-saint-malo-from-g1k27a.jpg" alt="" class="image">
      </div>
      <div class="scrollable-content">
        <div class="firefox-scroller">
          <h1>I am trying to do:</h1>
          <h3>1) make these gray div height 100% till bottom</h3>
          <h3>2) When content is more then this gray div should be scrollable or else not</h3>
          <p>
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
          </p>

        </div>
      </div>
    </div>
    <div class="column">
      <div class="image-holder">
        <img src="http://l7.alamy.com/zooms/19704c162b4446c984a50bfdb49b45ac/a-colour-image-taken-on-a-cloudy-dawn-of-the-town-of-saint-malo-from-g1k27a.jpg" alt="" class="image">
      </div>

    </div>
  </main>
</div>
&#13;
&#13;
&#13;