【发布时间】:2019-02-26 15:37:40
【问题描述】:
这是一个例子
.FlexContainer {
background: hsla(0,0%,0%,.1);
display: flex;
flex-direction: column;
max-height: 220px;
margin: 10px;
padding: 20px;
width: 300px;
overflow-y: auto;
}
.FlexItem {
background: hsla(0,0%,0%,.1);
width: 80%;
margin: 2px;
padding: 6px;
word-break: break-all;
white-space: normal;
cursor: pointer;
}
.FlexItem:hover{
background-color: red;
}
<html>
<head>
<title>demo</title>
</head>
<body>
<div class="FlexContainer">
<div class="FlexItem">
The contents is short in IE11.
</div>
<div class="FlexItem">
The contents is long - inside of this box are overflowing their container in IE11.
</div>
<div class="FlexItem">
The contents inside of this box are overflowing their container in IE11.
</div>
<div class="FlexItem">
The contents inside of this box are overflowing their container in IE11.
</div>
<div class="FlexItem">
The contents inside of this box are overflowing their container in IE11.
</div>
<div class="FlexItem">
The contents inside of this box are overflowing their container in IE11.
</div>
<div class="FlexItem">
The contents inside of this box are overflowing their container in IE11.
</div>
<div class="FlexItem">
The contents inside of this box are overflowing their container in IE11.
</div>
<div class="FlexItem">
The contents inside of this box are overflowing their container in IE11.
</div>
<div class="FlexItem">
The contents inside of this box are overflowing their container in IE11.
</div>
</div>
</body>
</html>
在 chrome 中它可以很好地工作 chrome work well
但是在 IE11 中这不是我所期望的。 IE11 work not expected
只有当容器高度小于 fex 项目并设置溢出-y:auto/scroll 时才会出现此问题。
有人可以帮我找出问题的原因吗?
感谢您的帮助。
【问题讨论】:
-
IE 已知有很多 flex-bugs...
width: 80%上的FlexItem导致了这个问题,如果你给它align-self: flex-start,你在 IE11 中也会遇到同样的问题...也许你可以避免在这里设置宽度:) -
我尝试设置宽度:自动,它可以工作。所有项目都扩大到 100%。但是如果设置宽度:100%(或其他百分比),结果和上面描述的一样。我不知道为什么。
-
IE11 在 flexbox 中设置宽度有问题,试过
flex-basis: 80%?
标签: javascript html css flexbox internet-explorer-11