tags:

views:

25

answers:

1

Hey guys

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>
+2  A: 

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;
}
Dustin Laine
sorry.. this just puts the search box all the way to the right.. I have margins to the right of the site.. and its NOT in the same vertical plane as the navigation bar..
Ram Bhat
Did you clear the float? Also post your code for the nav and parent container. It would help.
Dustin Laine
what do you mean by did i clear the float?
Ram Bhat
Check my updated answer, should explain some things.
Dustin Laine
Figured it out! Thanks a lot for your reply anyways!
Ram Bhat