字段集中的溢出和文本溢出

ska*_*alb 7 html css css3

这是一个溢出和文本溢出的工作示例(至少在webkit浏览器中),用于在缩小浏览器宽度时截断长文本:

<div>short</div>
<div style="overflow: hidden; text-overflow:ellipsis;">loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong</div>
<div>short</div>
<div>short</div>
<div>short</div>
Run Code Online (Sandbox Code Playgroud)

但是,如果我将这些div包装在fieldset中,则截断不再发生.我需要添加有关其他样式的任何想法吗?

破碎的例子:

<fieldset>
  <div>short</div>
  <div style="overflow: hidden; text-overflow: ellipsis;">loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong</div>
  <div>short</div>
  <div>short</div>
  <div>short</div>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

LB-*_*B-- 5

这是由于与怪异的行为fieldset小号,并且修复是更改浏览器设置为怪异值某些CSS属性.例如,这个例子也legend很好地切断了.它适用于我,但您可能需要阅读修复程序,了解如何让它在其他浏览器中运行.

fieldset
{
    min-width: 0;
    text-overflow: ellipsis;
    overflow: hidden;
}
legend
{
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
Run Code Online (Sandbox Code Playgroud)
<fieldset><legend>This is due to weird behavior with fieldsets, and the fix is to change certain CSS properties that browsers set to weird values.</legend><span>This is a loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong line of text that would normally overflow or cause the fieldset to widen and overflow itself.</span></fieldset>
Run Code Online (Sandbox Code Playgroud)