我有2个水平内联块div。母液体100%宽度:
<style>
.wrapper {
height: 100%;
width: 100%;
}
.chat-wrapper {
display: inline-block;
height: calc(100% - 25px);
width: 100%;
}
#chatbox {
height: 100%;
overflow-y: scroll;
float: left;
word-wrap: break-word;
}
</style>
<div class="wrapper">
<div class="chat-wrapper">
<div id="chatbox">
This div should fluid<br> 1<br>1<br>1<br>1<br>1<br>1<br>1<br>1<br>1<br>1<br>1<br>1<br>1<br>1<br>
</div>
<div> First row<br> Second row<br>This raw is longest = right div width<br><br> But less than 200px</div>
</div>
</div>
答案 0 :(得分:1)
基本上,您需要使用固定宽度浮动div。在您的情况下,翻转文本元素的顺序并float:right
第一个文本div,并设置max-width
以限制大小。请参阅here。
答案 1 :(得分:1)
如果您无法编辑HTML,则只能编辑CSS。
将元素显示为表格和表格单元格:http://jsfiddle.net/usgzhv6k/
.chat-wrapper {
display: table;
}
.chat-wrapper > div:nth-child(2) {
display: table-cell;
background-color: red;
max-width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#chatbox {
width: 100%;
background-color: green;
overflow-y: scroll;
word-wrap: break-word;
}
.create-message-wrapper {
background-color: cyan;
width: 100%;
display: table-row;
}