【发布时间】:2013-09-20 08:51:03
【问题描述】:
我正在尝试使用以下条件将两个 div 并排放置:
- 两个 div 必须保持在同一行。
- 必须优先考虑左侧 div。应在左侧 div 中显示尽可能多的文本,直至溢出时使用省略号。
- 右侧 div 的文本应右对齐。在溢出的情况下,应该使用省略号。
- 文本是动态的,因此不能使用百分比或固定宽度。
- 只需要在基于
webkit的浏览器上工作,所以首选CSS3解决方案。
以下是一些外观示例:
输入
<div class='left'>I should always fit. If not, ellipsis should be used.</div><div class='right'>Right align and fit me if space available here.</div>
输出
输入
<div class='left'>I should always fit. If not, ellipsis should be used. And some more text and more, and more text.</div><div class='right'>Right align and fit me if space available here.</div>
输出
输入
<div class='left'>This text is left aligned.</div><div class='right'>This text is right aligned.</div>
输出
【问题讨论】: