Flexbox容器中的省略号

jdl*_*dlm 55 css firefox

自从Firefox Nightly(35.0a1)的最新版本(?)发布以来,我一直遇到text-overflow: ellipsis一个Flexbox容器内部的问题flex-direction: row,每列的宽度为50%.

演示:

.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;
}
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)

在Nightly中,文本将泄漏到其容器外部,而不会附加...到最后.在Chrome和Firefox Stable中,它可以正常运行.

jdl*_*dlm 100

这最终被追溯到最近Firefox Nightly的变化.简而言之,选择器min-width: 0上的设置.column将使其按预期工作.

这里可以找到更全面的答案.值得注意的是

"基本上:除非你明确指定"min-width"或"width"或"max-width",否则flex项目将拒绝收缩到其最小固有宽度以下."

工作方案:

.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;
}
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)