我有兩個div,我想內聯(一個在左邊,一個在右邊)。右邊那個包含一行文字。我希望它始終是一行文本,並在必要時省略。我不能正確地進行內聯,因爲當我的文本太長時,正確的div跳轉到左側。例如:內嵌塊無法按預期方式使用長內容?
<!doctype>
<html>
<head>
<style type="text/css">
#panelLeft {
display: inline-block;
width: 50px;
height: 20px;
background-color: #f00;
}
#panelRight {
display: inline-block;
background-color: #0f0;
/* width: 200px; */ works ok if explicitly sized
}
#test {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div id="panelLeft">
</div>
<div id="panelRight">
<div id="test">
This is some text that's longer than usual and that I'd like to have ellipsized, and forced to a single line, always.
</div>
</div>
</body>
</html>
如果代替我指定panelRight的寬度(其等於或小於剩餘空間短),然後我的div是在同一直線上,並且ellipsizing正確顯示。如果我不知道panelRight的確切寬度,我怎麼才能得到這個工作?
感謝