If you want to achieve this specific layout, you can utilize CSS table-cells.
To implement this layout, make some adjustments to your HTML code:
<div id="header">
<div class="container">
<div class="logoBar">
<img src="http://placehold.it/50x40" />
</div>
<div id="searchBar">
<input type="text" />
</div>
<div class="button orange" id="myAccount">My Account</div>
<div class="button red" id="basket">Basket (2)</div>
</div>
</div>
You just need to remove the wrapper element around the two .button
elements.
Add the following CSS styling:
#header {
background-color: #323C3E;
width:100%;
}
.container {
display: table;
width: 100%;
}
.logoBar, #searchBar, .button {
display: table-cell;
vertical-align: middle;
width: auto;
}
.logoBar img {
display: block;
}
#searchBar {
background-color: #FFF2BC;
width: 90%;
padding: 0 50px 0 10px;
}
#searchBar input {
width: 100%;
}
.button {
white-space: nowrap;
padding:22px;
}
Set display: table
to .container
with a width of 100%.
For .logoBar
, #searchBar
, and .button
, apply display: table-cell
.
Adjust the width of #searchBar
to 90%, causing other elements to adjust accordingly.
Use text-align and vertical-align in the table cells as needed.
You can view a demo here: http://jsfiddle.net/audetwebdesign/zWXQt/