【问题标题】:Divs with flex property overlaps具有 flex 属性的 div 重叠
【发布时间】:2015-08-25 14:54:28
【问题描述】:

我正在使用 angular 和 angular-material 来创建自定义指令。一切都是正确的,除了当我将指令链接函数中的 flex 属性添加到一个 div 时,内容会重叠。

例子:

http://jsfiddle.net/9crdbz4t/

<div layout="row">
    <div flex=10>example.long.email@example.com.zzz</div>
    <div flex>Some other text that require more space</div>
</div>

如果内容大于 flex 值,我该如何调整?

【问题讨论】:

  • 也许添加 word-wrap: break-word;在第一个 Div

标签: javascript angularjs angularjs-directive angular-material


【解决方案1】:

Flex-box 不会打断连续的文本。但是你有一个优雅的解决方案。这样可以避免重叠。

<div flex layout="row" >
    <div flex="10" style="text-overflow: ellipsis;overflow: hidden;">example.long.email@example.com.zzz</div>
    <div flex >Some other text that require more space</div>
</div>

或者你可以使用word-wrap: break-word;

<div  layout="row" >
        <div flex="10" style="word-wrap: break-word;">example.long.email@example.com.zzz</div>
        <div flex >Some other text that require more space</div>
    </div>

http://jsfiddle.net/9crdbz4t/13/

【讨论】:

  • 谢谢,这两种解决方案都可以在不同的情况下提供帮助
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-04-23
  • 2020-05-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-19
  • 1970-01-01
相关资源
最近更新 更多