我需要在同一行上的标题和按钮,如有必要,使用省略号。
这是一个小提琴:http: //jsfiddle.net/epyFT/1/
我希望输出看起来像这样:
_________________________________________________________
| |
| Header goes here [button] |
| |
---------------------------------------------------------
或者
_________________________________________________________
| |
| Super, super, super, super long header... [button] |
| |
---------------------------------------------------------
或使用较小的窗口:
____________________________
| |
| Header goes... [button] |
| |
----------------------------
该按钮不应该浮动到下一行。我怎样才能做到这一点?
HTML
<div class="container">
<h2>This is the header that should never wrap and elipse if it doesn't fit</h2>
<button>Button</button>
</div>
<div class="container">
<h2>Header</h2>
<button>Button</button>
</div>
CSS
.container {
width:100%;
}
h2 {
display:inline;
min-width:200px;
overflow: hidden; white-space: nowrap; text-overflow: ellipsis; word-break: break-all; word-wrap: break-word;
}
button {
width:100px;
}
奖金
获得第二个(固定宽度)按钮以向右拉的额外功劳。
_________________________________________________________
| |
| Header goes here [button1] [button2] |
| |
| |
| Super, super, super, super long... [button] [button2] |
| |
---------------------------------------------------------