Reputation: 5832
All,
I am trying to align a few elements, floated right and inline but I am not having much luck.
Here is what I am trying to do (see 3 elements on the right inside light blue header )
I am ending up with this:
Live Example http://jsfiddle.net/castonzo/3G4jb/
My HTML
<div id="addCounselorSection">
<div class="blue-toolbar">
<span class="blue-toolbar-title">Club Counselors</span>
<div class="blue-toolbar-search-tools">
<div class="blue-toolbar-search-tools-title">Find counselors</div>
<div><input type="text" /></div>
<div class="blue-toolbar-search-tools-link"><a href="#">Add</a></div>
</div>
</div>
</div>
My CSS
/****** Toolbar ****************/
.blue-toolbar {
background-color: #086CA1;
border: 1px solid #235B79;
height: 45px;
width: auto;
margin-bottom: 13px;
margin-top: 20px;
position: relative;
}
.blue-toolbar-title {
position: absolute;
bottom: 0;
left: 0;
float:left;
padding-left:5px;
padding-bottom:4px;
color:#ffffff;
font-weight:bold;
font-size:18px;
}
.blue-toolbar-search-tools {
float: right;
width: auto;
display: block;
}
.blue-toolbar-search-tools-title {
color:#ffffff;
font-weight:bold;
font-size:14px;
float: left;
position: absolute;
bottom: 0;
right: 0;
}
.blue-toolbar-search-tools a{
color:#ffffff;
font-weight:bold;
}
Upvotes: 0
Views: 69
Reputation: 199
Try this :
CSS :
<style>
/****** Toolbar ****************/
.blue-toolbar {
background-color: #086CA1;
border: 1px solid #235B79;
height: 45px;
width: auto;
margin-bottom: 13px;
margin-top: 20px;
position: relative;
}
.blue-toolbar-title {
position: absolute;
bottom: 0;
left: 0;
float:left;
padding-left:5px;
padding-bottom:4px;
color:#ffffff;
font-weight:bold;
font-size:18px;
}
.blue-toolbar-search-tools {
float: right;
width: auto;
display: block;
}
.blue-toolbar-search-tools-title {
color:#ffffff;
font-weight:bold;
font-size:14px;
float: left;
bottom: 0;
right: 0;
float:left;
padding:12px 5px;
}
.blue-toolbar-search-tools a{
color:#ffffff;
font-weight:bold;
}
.blue-toolbar-search-tools-input{
padding:8px 5px;
float:left;
}
.blue-toolbar-search-tools-link{
padding:8px 5px;
float:left;
}
</style>
HTML:
<div id="addCounselorSection">
<div class="blue-toolbar">
<span class="blue-toolbar-title">Club Counselors</span>
<div class="blue-toolbar-search-tools">
<div class="blue-toolbar-search-tools-title">Find counselors</div>
<div class="blue-toolbar-search-tools-input"><input type="text" /></div>
<div class="blue-toolbar-search-tools-link"><a href="#">Add</a></div>
</div>
</div>
</div>
Upvotes: 1
Reputation: 1951
By default div
is block element so you have either display it inline or float it:
.blue-toolbar-search-tools div{ float: left; }
or
.blue-toolbar-search-tools div{ display: inline; }
Upvotes: 0
Reputation: 241198
Remove the absolute positioning and change the display
of all three children elements from block
to inline-block
. As for vertical positioning, just add a margin to the parent element.
.blue-toolbar-search-tools {
float: right;
margin:16px 10px;
}
.blue-toolbar-search-tools > div {
display:inline-block;
}
Upvotes: 2