help positioning the search bar
I have my navigation bar using unordered links and using jquery for ui effects. This works fine. Now I have designed a search bar which matches 开发者_开发知识库the theme of the bar and wanna position it to the right of the nav bar. kinda like the vimeo website..
The problem is that i cannot include it in the same list cos i dont want the jquery effects to be applied to the search bar. How do i position it to the right of nav bar??
Heres the css i tried but doesnt work
.search{
background-image:url('search.jpg');
margin-top:inherit;
margin-left:inherit;
width:200px;
height:40px;
}
here goes the html
<div class="search">
<input type="text" id="searchField" />
<img src="go.jpg" alt="Search" onclick="alert('You clicked on search button')" /></div>
There are a couple options The best option depends on your entire layout. Here are two basic CSS implementations of horizontal navigation list and search inline with each other.
HTML
<div id="Navigation">
<ul>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
<div class="search">
<input type="text" id="searchField" />
<img src="go.jpg" alt="Search" onclick="alert('You clicked on search button')" />
</div>
<br style="clear: both;" />
</div>
CSS Float
#Navigation ul
{
list-style-type: none;
margin: 0;
padding: 0;
}
#Navigation ul li
{
list-style-type: none;
margin: 0;
padding: 0;
float: left;
}
#Navigation ul li a
{
display: block;
height: 40px;
width: 50px;
}
.search
{
background-image:url('search.jpg');
float: right;
width:200px;
height:40px;
}
CSS Absolute
#Navigation
{
position: relative;
}
#Navigation ul
{
list-style-type: none;
margin: 0;
padding: 0;
}
#Navigation ul li
{
list-style-type: none;
margin: 0;
padding: 0;
float: left;
}
#Navigation ul li a
{
display: block;
height: 40px;
width: 50px;
}
.search
{
position: absolute;
background-image:url('search.jpg');
top: 0;
right: 10px;
width:200px;
height:40px;
}
精彩评论