自从最新(?)版本的 Firefox Nightly (35.0a1) 以来,我一直遇到一个问题text-overflow: ellipsis
在 Flexbox 容器内flex-direction: row
,每列宽 50%。
Demo:
.container {
width: 300px;
background: red;
}
.row {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.column {
flex-basis: 50%;
}
.column p {
background: gold;
/* Will not work in Firefox Nightly 35.0a1 */
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
<div class="container">
<div class="row">
<div class="column">
<p>Captain's Log, Stardate 9529.1: This is the final cruise of the starship Enterprise under my command. This ship and her history will shortly become the care of another crew. To them and their posterity will we commit our future. They will continue the voyages we have begun and journey to all the undiscovered countries boldly going where no man, where no one has gone before.</p>
</div>
<div class="column">
<p>Captain's Log, Stardate 9529.1: This is the final cruise of the starship Enterprise under my command. This ship and her history will shortly become the care of another crew. To them and their posterity will we commit our future. They will continue the voyages we have begun and journey to all the undiscovered countries boldly going where no man, where no one has gone before.</p>
</div>
</div>
</div>
在 Nightly 中,文本将泄漏到其容器之外,并且不会附加...
在最后。在 Chrome 和 Firefox Stable 中,它按预期工作。
这最终被追踪到 Firefox Nightly 最近的变化。长话短说,设定min-width: 0
on the .column
选择器将使其按预期工作。
可以找到更全面的答案here https://bugzilla.mozilla.org/show_bug.cgi?id=1086218#c4。值得注意的是:
“基本上:弹性项目将拒绝收缩到其最小固有宽度以下,除非您明确指定它们的“最小宽度”或“宽度”或“最大宽度”。”
工作解决方案:
.container {
width: 300px;
background: red;
}
.row {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.column {
/* This will make it work in Firefox >= 35.0a1 */
min-width: 0;
flex-basis: 50%;
}
.column p {
background: gold;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
<div class="container">
<div class="row">
<div class="column">
<p>Captain's Log, Stardate 9529.1: This is the final cruise of the starship Enterprise under my command. This ship and her history will shortly become the care of another crew. To them and their posterity will we commit our future. They will continue the voyages we have begun and journey to all the undiscovered countries boldly going where no man, where no one has gone before.</p>
</div>
<div class="column">
<p>Captain's Log, Stardate 9529.1: This is the final cruise of the starship Enterprise under my command. This ship and her history will shortly become the care of another crew. To them and their posterity will we commit our future. They will continue the voyages we have begun and journey to all the undiscovered countries boldly going where no man, where no one has gone before.</p>
</div>
</div>
</div>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)