您可以结合使用display:inline-block
withvertical-align:top
和删除元素之间的空格-请注意 HTML 注释(有关更多信息,请参阅此答案)并使用CSS calc()。
HTML:
<div class="parent">
<div class="left">
<p>Curabitur tristique, purus a dapibus laoreet, tellus massa tempor turpis, eget tristique turpis lorem vitae nulla. Morbi venenatis, mi vel sodales sollicitudin, quam mauris vulputate nibh, sed convallis arcu nisi sed sem. Suspendisse potenti. Cras lobortis porttitor libero, et commodo risus commodo sit amet. Etiam vitae justo ac est aliquet pharetra. Integer eu auctor mi, a molestie lacus. Morbi vel diam ut sem rutrum eleifend vel quis sapien. Phasellus vel faucibus eros, in commodo neque.</p>
</div><!--
--><div class="right">
</div>
</div>
CSS:
html,body,.parent{
width:100%;
height:100%;
}
.right{
height:100%;
width:100px;
background:red;
display:inline-block;
vertical-align:top;
}
.left{
width:calc(100% - 100px);
height:100%;
background:blue;
display:inline-block;
vertical-align:top;
}
p{
white-space: nowrap;
overflow: hidden;
text-overflow:ellipsis;
}
JSFiddle
可以使用 calc()
注意:我使用Eric Meyer 的“Reset CSS”2.0