フロートを使用したくない場合は、テーブルセルを使用した次のソリューションを参照してください。
このソリューションでは、CSSの「display:table」を使用して、100%流動的なテキストオーバーフローの省略記号を使用します。フロートは必要ありません!
HTML:
<div class='header'>
<div class='header-title'>
<div class="fluid-ellipsis-container">
<div class="fluid-ellipsis-content">
This solution uses 'display: table' in CSS for 100% fluid text-overflow ellipsis. <strong>NO FLOATS needed!</strong> It's important to note that this works because of the browser's process of calculating the 'table-cell' width within a fixed layout scheme of the parent 'table' div, in effect creating a "fixed" table-cell width on each browser reflow/paint, hence applying the ellipsis property without dynamic width issues.
</div>
</div>
</div>
<div class='header-toolbar'>
<button>Create</button>
</div>
</div>
CSS:
.header, .header-title, .header-toolbar {
box-sizing: border-box;
border: 1px solid rgba(150,150,150,0.5);
padding: 5px;
}
.header{
display: table;
}
.header-title {
display: table-cell;
vertical-align:middle;
width: 85%;
}
.header-toolbar {
display: table-cell;
width: 15%;
text-align: center;
vertical-align: middle;
}
.fluid-ellipsis-container{
display:table;
table-layout: fixed;
width: 100%;
}
.fluid-ellipsis-content{
display: table-cell;
vertical-align: middle;
white-space:nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
これは、親の「テーブル」divの固定レイアウトスキーム内で「テーブルセル」幅を計算するブラウザのプロセスのために機能し、実際には各ブラウザのリフローでセルに「固定」幅を作成することに注意することが重要です。ペイントのサイズ変更。したがって、動的な幅の問題なしに省略記号プロパティを適用します。
http://cssdeck.com/labs/j5zk46la