I'm afraid it's a bit more complicated than that.
I need a fluid width header (h2
) that never wraps, with a left aligned button (.btn1
), and all without overlapping a fixed-width right button (.btn2
).
If that sounds too complicated, how about a well written Fiddle (http://jsfiddle.net/8ZtU5/) and some beautiful ASCII art?
__________________________________________________
| |
| This header is really really... [One] [Two] |
| |
--------------------------------------------------
__________________________________________________
| |
| This header is short [One] [Two] |
| |
--------------------------------------------------
_________________________________
| |
| This header is... [One] [Two] |
| |
---------------------------------
What do you think? Can you help?
HTML: (http://jsfiddle.net/8ZtU5/)
Note: extra wrappers are just for convenience. Nothing is necessary except the rendered result.
<div class="container">
<div class="fluid-width">
<div class="no-wrapping">
<h2>This header is really really really really really really really long</h2>
</div>
<button class="btn1">One</button>
</div>
<div class="fixed-width">
<button class="btn2">Two</button>
</div>
</div>
<div class="container">
<div class="fluid-width">
<div class="no-wrapping">
<h2>This header is short</h2>
</div>
<button class="btn1">One</button>
</div>
<div class="fixed-width">
<button class="btn2">Two</button>
</div>
</div>
Base CSS:
.container {
margin:20px 0;
width:100%;
min-width:300px;
background:#eee;
}
.fluid-width {
min-width:200px;
display:inline-block;
}
.fixed-width {
width:100px;
max-width:100px;
min-width:100px;
display:inline-block;
}
.no-wrapping {
overflow: hidden; white-space: nowrap; text-overflow: ellipsis; word-break: break-all; word-wrap: break-word;
}
h2 {
display:inline;
}
No need to guess... it's all on the fiddle if you want to play: http://jsfiddle.net/8ZtU5/