【发布时间】:2018-11-22 04:05:00
【问题描述】:
我创建了一个英雄,其中文本位于图像的左侧,使用 flexbox 自动将文本定位在 div 的中心,相对于图像。
我使用了旧的和新的 IE 前缀来使其能够在最新版本的 IE 上运行,但它似乎不适用于 IE 10。文本 div 似乎延伸到整个列的宽度,在右边的图像后面。关于为什么会发生这种情况的任何想法?
代码:
.hero {
background-color: #3c763d;
text-align: center;
}
.flex {
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-box;
display: -moz-box;
display: flex;
-ms-flex-wrap: wrap;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
flex-direction: row;
}
.d-flex {
-ms-flex-align: center!important;
-webkit-box-align: center!important;
align-items: center!important;
display: -ms-flexbox!important;
display: -webkit-box;
display: flex;
margin-top: 0;
margin-left: auto;
margin-right: auto;
-moz-flex: 1 1 15em;
-webkit-box-flex: 1;
-ms-flex: 1 1 15em;
flex: 1 1 15em;
}
.img-responsive {
display: block;
max-width: 100%;
height: auto;
}
<section class="section hero">
<div class="container">
<div class="row flex">
<div class="col-xs-12 col-md-6 d-flex">
<div>
<h2>Headline</h2>
<p>Paragraph text</p>
</div>
</div>
<div class="col-xs-12 col-md-6">
<div>
<img class="img-responsive" src="http://pngplay.com/wp-content/uploads/1/Laptop-PNG-Image.png">
</div>
</div>
</div>
</div>
</section>
【问题讨论】:
-
此链接可能有用——IE10 有不同的 flexbox 实现,但可能有解决方法:github.com/philipwalton/flexbugs
-
flex 不能很好地与 IE10 配合使用,并且存在一些问题,那么您的 flex 方向在哪里?并且很难在帖子中看到您的问题
标签: css twitter-bootstrap flexbox internet-explorer-10