Reputation: 21
I created a drop down menu bar in lists and css and anytime I zoom in/out or adjust browser window size the contents on the bar shift to the left when zoom out and right when zoom in. Also, when I adjust the browser window size the navigational bar doesn't move with the rest of the page to the left. So if someone opens a new browser window and it's smaller than a full screen, the contents in my navigation bar would be in the wrong place (too far left or right). Does anyone know how I can fix this? Thank you for any help in advance. I did research previous questions that were similar to mine but it seems any time I try those solutions they don't work for me.
Here's the link for the menu bar I've created. http://www.stlpublicradio.org/info/press-test.php#
<code><div id="wrapper">
<ul id="nav">
<li>
<a href="#">main menu 1</a>
<ul>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#">6</a></li>
</ul>
</li>
<li>
<a href="#">main menu 2</a>
<ul>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5/a></li>
<li><a href="#">6</a></li>
<li><a href="#">7</a></li>
<li><a href="#">8</a></li>
</ul>
</li>
<li>
<a href="#">main menu 3</a>
<ul>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
</ul>
</li>
<li>
<a href="#">main menu 4</a>
<ul>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
</ul>
</li>
</ul>
</div>
</code>
<code>
THE CSS
#wrapper {
width: 100%;
}
#nav{
background: #383838; /* Old browsers */
background: -moz-linear-gradient(top, #383838 21%, #131313 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(21%,#383838), color-stop(100%,#131313)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #383838 21%,#131313 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #383838 21%,#131313 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #383838 21%,#131313 100%); /* IE10+ */
background: linear-gradient(to bottom, #383838 21%,#131313 100%); /* W3C */
list-style:none;
font-weight:bold;
float:left;
width:100%;
font-family: Arial, Helvetica, sans-serif;
list-style: none;
position:relative;
z-index:100;
font-size: 100%;
height: 40px;
display:inline-block;
margin: 0 auto;
white-space:nowrap;
padding-left:500px;
text-align:center;
}
#nav li a{
border-left: thin;
border-left-style:solid;
border-left-width:thin;
border-left-color:#cccccc;
line-height: 30px;
padding-left: 5px;
width: 100%;
}
#nav li{
position: absolute;
display:block;
padding-top:0px;
margin-top:0;
float:left;
margin-right:10px;
position:relative;
color: #99CCCC;
}
#nav a{
font-size: 14px;
margin:0;
display:block;
padding:5px;
color:#fff;
text-decoration:none;
}
#nav a:hover{
margin-top:0;
text-decoration:none;
color:#fff;
}
/*dropdown start*/
#nav ul{
height: 400px;
background:#fff;
background:rgba(255,255,255,0);
list-style:none;
position:absolute;
left:-9999px;
padding-left: 275px;
padding-top:0px;
display:block;
width: 190px;
/*display:block;
color: #cccccc;
font-family: Helvetica, Arial;
font: bold;
margin: 0;
text-align: left;*/
}
#nav ul li{
text-align:left;
float:none;
margin-left: 275px;
padding-left: 0px;
display: block;
background-color: #333;
font-family: Arial, Helvetica, sans-serif;
display: inline;
list-style: none;
margin: 0;
}
#nav li a img {
padding-left: 3px;
}
#nav ul a{
font-size: 12px;
background-color:#333;
white-space:nowrap;
}
#nav li ul li a {
margin-top: 0px;
padding-top: 5px;
}
#nav li a {
color: #cccccc;
}
#nav li:hover ul{
left:0;
display: block;
left:-275px;
}
#nav li:hover a{
text-decoration:none;
}
#nav li:hover ul a{
text-decoration:none;
}
#nav li:hover ul li a:hover{
background:#333;
}
</code>
Upvotes: 2
Views: 3393
Reputation: 24703
In your nav
you have padding-left: 500px;
, that's a lot of padding and will cause you issues on smaller screens and browser resizing.
Upvotes: 1