Phi*_*phy 14 html ellipsis css3
我正在尝试使用以下标准将两个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>
Run Code Online (Sandbox Code Playgroud)
产量
输入
<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>
Run Code Online (Sandbox Code Playgroud)
产量
输入
<div class='left'>This text is left aligned.</div><div class='right'>This text is right aligned.</div>
Run Code Online (Sandbox Code Playgroud)
产量
我有它的例外,当有空的空间时我的右边的div正在吃它(文本右对齐).你没有把它列为一个问题,所以我不确定这是不是你是如何绘制它的?在这里小提琴:http://jsfiddle.net/mdares/fSCr6/
HTML:
<div class="container">
<div class="left">Some Text, Repeat, Repeat, Repeat, ,Some Text, and then: </div>
<div class="right">other Text ttt other Text tttother Text tttother Text ttt</div>
</div>
<p />
<div class="container">
<div class="left">Some Text, Repeat, Repeat, Repeat, ,Some Text, Some Text, Repeat, Repeat, Repeat, ,Some Text,</div>
<div class="right">other Text ttt other Text tttother Text tttother Text ttt</div>
</div>
<p />
<div class="container">
<div class="left">Some Text, Repeat, Repeat, Repeat, ,Some Text, </div>
<div class="right">other Text ttt</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.container {
width: 600px;
}
.left {
max-width: 100%;
background:red;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
-ms-text-overflow:ellipsis;
float: left;
}
.right {
background:yellow;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
-ms-text-overflow:ellipsis;
text-align: right;
}
Run Code Online (Sandbox Code Playgroud)
最后: