css – 如何修复IE中的flex列高度错误

前端之家收集整理的这篇文章主要介绍了css – 如何修复IE中的flex列高度错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在IE中我遇到了一个问题,我的flex列被拉伸的原因不明.我需要每个弹性项目的图像高度和宽度始终相同,并且响应所以我需要它们100%.我还需要弹性页脚始终与其他页面处于同一级别,无论弹性名称是否超过1行,它都会粘到容器的底部.

@H_404_5@.flex-container { display: flex; border: 1px solid red; } .flex-item-wrapper { display: flex; border: 1px solid green; flex-direction: column; width: 185px; } .link-spanner { position: absolute; height: 100%; width: 100%; top: 0; left: 0; } .flex-header { width: 100%; display: flex; flex-direction: column; align-items: center; margin-bottom: auto; } .image-container { margin-top: 5px; position: relative; width: 100%; } img { height: 100%; width: 100%; } .flex-item-name { max-width: 100%; text-align: center; } @H_404_5@
最佳答案
除了这个post/answer,如果加上min-height:1px;对于.flex-header和.image-container,它也可以在IE11中运行.

..我不知道为什么,虽然根据这个Microsoft bug report,它迫使IE重新计算基于图像的大小.

Updated fiddle

@H_404_5@.flex-header { width: 100%; display: flex; flex-direction: column; align-items: center; margin-bottom: auto; min-height: 1px; } .image-container { margin-top: 5px; position: relative; width: 100%; min-height: 1px; }

实际上,如果你添加-ms-flex-negative:0也可以.到.flex-header和.image-container

猜你在找的CSS相关文章