微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

.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;
}

jsfiddle

最佳答案
除了这个post/answer,如果加上min-height:1px;对于.flex-header和.image-container,它也可以在IE11中运行.

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

Updated fiddle

.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

原文地址:https://www.jb51.cc/css/427513.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。