'Making a navigation bar that includes a search bar
I'm working on a navigation bar for my website, and I want to add a search box to it. I'm using a text-field, and I've positioned it with CSS so that it's aligned perfectly, except depending on the resolution, it shifts around. How can I make sure it stays in one position? For reference, it's kind of like on Apple's website except bigger.
Here's the navbar part of my HTML code:
<img id="navbar" src="images/Navbar.png" alt="Navigation"/>
<form method="get" action="" class="search">
<input class="msb" maxlength="2048" id="searchBox" size="40" title="Search" value="" lang="en" />
<input value="Search" id="submitButton" type="submit" />
</form>
<ul id="navlinks">
<li id="navHome"><a href="index.php">Home</a></li>
<li id="navSubmit"><a href="submit.html">Submit</a></li>
<li id="navArchive"><a href="archive.html">Archive</a></li>
<li id="navApps"><a href="apps.html">Apps</a></li>
<li id="navContact"><a href="contact.html">Contact</a></li>
</ul>
and here's my CSS (note that the navlinks aren't lined up either so the #navlink section isn't really relevant:
div#adholder
{
width:728px;
height:90px;
align:center;
}
ul#navlinks
{
postition: absolute;
right: 280px;
margin:20px;
padding:0;
list-style:none;
width:525px;
}
#searchBox
{
position: fixed;
left: 890px;
top: 250px;
height: 30px;
}
/*#searchBox
{
position:absolute;
right:150;
top:150;
width: 300px;
height: 35px;
}*/
#submitButton
{
display: none;
}
ul#navlinks li
{
display: inline;
}
ul#navlinks li a
{
text-decoration: none;
padding: 5px 0;
width:100px;
background: none;
color:#000;
float:left;
}
(For some reason the code formatter isn't working...)
This is how it looks on my 1366x768 laptop screen:
Solution 1:[1]
use position:absolute;
and set all four parameter top: bottom: right: left:
in style
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | diEcho |