インラインにしたい 2 つの div があります (左側に 1 つ、右側に 1 つ)。右側にはテキスト行が含まれています。常に1行のテキストにして、必要に応じて楕円形にしたい. テキストが長すぎると、右の 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 が同じ行に表示され、省略表示が正しく表示されます。panelRight の正確な幅がわからない場合、どうすればこれを機能させることができますか?
ありがとう