基于this post我尝试使左侧div填满剩余空间,左侧和右侧应始终位于一行中,右侧div应完全可见。让剩余空格填充剩余空间
如何做到这一点?
#left {
width: 100%;
background-color: #ff0000;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
float: left;
}
#right {
float: right;
background-color: #00FF00;
}
<body>
<div>
<div id="left">
left text should have the remaining width and shortended if it is too long lorem ipsum minion dolor
</div>
<div id="right">
this text is dynamic - should be fully visibile
</div>
</div>
</body>
编辑:
Flex的盒子答案不工作。它看起来像,如果绿色文字变得更短:
我要的是绿色格变小了,当文本短。
你想同时在一行div?为什么不在左边div浮动? –
是的正好......增加了左边的浮动,没有帮助 – Alex