Jus*_*usi 57 html css flexbox internet-explorer-11
我在IE11上遇到了与flexbox有关的问题,虽然我知道有很多已知问题,但我还是找不到解决方案......
<div class="latest-posts">
<article class="post-grid">
<img src="http://lorempixel.com/image_output/cats-q-c-640-480-4.jpg" alt="" />
<div class="article-content">
<h2>THIS IS POST TITLE</h2>
<p>BLAH</p>
</div>
</article>
</div>
Run Code Online (Sandbox Code Playgroud)
而CSS ......
img {
max-width: 100%;
}
.latest-posts {
margin: 30px auto;
}
article.post-grid {
width: 375px;
float: left;
margin: 0 25px 100px 0;
padding-bottom: 20px;
background-color: #fff;
border: 1px solid #f3f3f3;
border-radius: 2px;
font-size: 14px;
line-height: 26px;
display: flex;
flex: 1 0 auto;
flex-direction: column;
justify-content: flex-start;
align-content: flex-start;
}
.article-content {
padding: 20px 35px;
}
Run Code Online (Sandbox Code Playgroud)
图像在弹性容器内被拉伸.
应用align-items: flex-start(我想,因为"拉伸"是默认值...)或justify-content: flex-start似乎不起作用.
Codepen:我的意思的例子
我究竟做错了什么?
G-C*_*Cyr 142
为了避免这种有趣的行为,你可以重置flex-shrink属性.
这看起来像一个bug,尽管微软说:
设置弹性项目的弹性收缩因子或负弹性.弹性收缩因子决定了弹性项目相对于弹性容器中其他项目的收缩程度.
如果省略,则元素的负灵活性为"0".负值无效.
来源:https : //msdn.microsoft.com/en-us/library/jj127297%28v=vs.85%29.aspx https://msdn.microsoft.com/en-us//library/hh772069%28v= vs.85%29.aspx
img {
max-width: 100%;
flex-shrink: 0;
}
Run Code Online (Sandbox Code Playgroud)
img {
max-width: 100%;
flex-shrink: 0;
}
.latest-posts {
margin: 30px auto;
}
article.post-grid {
width: 375px;
float: left;
margin: 0 25px 100px 0;
padding-bottom: 20px;
background-color: #fff;
border: 1px solid #f3f3f3;
border-radius: 2px;
font-size: 14px;
line-height: 26px;
display: flex;
flex: 1 0 auto;
flex-direction: column;
justify-content: flex-start;
align-content: flex-start;
}
article.post-grid .article-content {
padding: 20px 35px;
}Run Code Online (Sandbox Code Playgroud)
<div class="latest-posts">
<article class="post-grid">
<img src="http://lorempixel.com/image_output/cats-q-c-640-480-4.jpg" alt="" />
<div class="article-content">
<h2>THIS IS POST TITLE</h2>
<p>Society excited by cottage private an it esteems. Fully begin on by wound an. Girl rich in do up or both. At declared in as rejoiced of together.</p>
</div>
</article>
<article class="post-grid">
<img src="http://lorempixel.com/image_output/cats-q-c-640-480-4.jpg" alt="" />
<div class="article-content">
<h2>MUCH LONGER POST TITLE TO ILLUSTRATE HEIGHTS</h2>
<p>Recommend new contented intention improving bed performed age.</p>
</div>
</article>
<article class="post-grid">
<img src="http://lorempixel.com/image_output/cats-q-c-640-480-4.jpg" alt="" />
<div class="article-content">
<h2>SHORT TITLE</h2>
<p>Merry alone do it burst me songs. Sorry equal charm joy her those folly ham. In they no is many both. Recommend new contented intention improving bed performed age. Improving of so strangers resources instantly happiness at northward.</p>
</div>
</article>
</div>Run Code Online (Sandbox Code Playgroud)
http://codepen.io/anon/pen/KzBOvq
Rik*_*eek 12
我在横轴上有图像拉伸(拉伸高度,使用flex-direction:row).
这个stackoverflow Q/A帮助我解决了这个问题:
我必须在我的img上设置以下css:
align-self: flex-start;
Run Code Online (Sandbox Code Playgroud)
根据您的目标,您可能需要另一个值而不是flex-start ofcourse.我的意思是将我的图像放在行的顶部.