gpt4 book ai didi

css - 显示 Flex 单元 IE10 内的断字/自动换行

转载 作者:行者123 更新时间:2023-12-04 14:28:46 25 4
gpt4 key购买 nike

在 IE10 中显示 Flex 的单元格内出现断字问题。它在 chrome 上的行为正确,比较 chrome 中的 fiddle 以查看预期的行为。

在示例中,表格中的第一个单元格应该断字并且不会流入下一个单元格。

我尝试了多种断字和换行(chrome/mozilla 中都不需要),但它们在 IE 中不起作用。

感谢任何帮助。

jsFiddle

HTML:

<div class="container">
<div class="table">
<div class="table-row">
<div class="table-row-cell">Long string input that we want to word break and not overflow into other cell</div>
<div class="table-row-cell">short</div>
<div class="table-row-cell">short</div>
<div class="table-row-cell">short</div>
</div>
<div class="table-row">
<div class="table-row-cell">normal length</div>
<div class="table-row-cell">short</div>
<div class="table-row-cell">short</div>
<div class="table-row-cell">short</div>
</div>
</div>
</div>

CSS:

html, body { padding: 0; margin: 0; }
.container {
width: 400px;
}
.table {
display: -webkit-box;
display: -moz-box;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: column nowrap;
-moz-flex-flow: column nowrap;
flex-flow: column nowrap;
-ms-flex-direction: column;
-ms-flex-wrap: nowrap;
-webkit-box-pack: justify;
-moz-box-pack: justify;
-ms-flex-pack: justify;
box-pack: justify;
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
-o-justify-content: space-between;
justify-content: space-between;
}
.table-row {
display: -webkit-box;
display: -moz-box;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row nowrap;
-moz-flex-flow: row nowrap;
flex-flow: row nowrap;
-ms-flex-direction: row;
-ms-flex-wrap: nowrap;
}
.table-row-cell {
display: -webkit-box;
display: -moz-box;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-grow: 1;
-moz-flex-grow: 1;
flex-grow: 1;
-ms-flex-positive: 1;
-webkit-flex-basis: 0;
-moz-flex-basis: 0;
flex-basis: 0;
-ms-flex-preferred-size: 0;
/* word-wrap: break-word;
overflow-wrap: break-word;
word-break: break-all;
word-break: break-word;
-ms-word-wrap: break-word;
-ms-overflow-wrap: break-word;
-ms-word-break: break-all;
-ms-word-break: break-word;*/
padding: 0.5em;
}

最佳答案

这实际上是 IE 10 和 11 中 Flexbox 的一个已知错误 ( https://github.com/philipwalton/flexbugs#12-inline-elements-are-not-treated-as-flex-items )。

我能想到的唯一可以帮助解决您的问题的解决方法是将溢出的内容包装在 block 级元素中,然后在该元素上设置最大宽度:

<div class="table-row-cell">
<p style="display: block; max-width: 100px;">
Long string input that we want to word break and not overflow into other cell
</p>
</div>

该解决方案的结果:

IE acting up

关于css - 显示 Flex 单元 IE10 内的断字/自动换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32478360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com