Tye Lucas Tye Lucas - 4 months ago 7
HTML Question

NAV Bar not working properly with lower resolutions

For some odd reason when using a laptop or mobile device or even lower resolutions that 1080p the NAV bar is not working as intended, I can not select items on the right side of the bar. This has me stumped, anyone have any ideas why this would be?

HTML:

<nav>

<ul>
<li><div hidden id="online"><span hidden></span><span hidden class="usersonline"></span></div></li>
<li><a href="index.php">Home</a></li>
<li><a href="supportliberty.php">Support Liberty</a></li>
<li><a href="share.php">Your KTR Success</a></li>
<li><a href="libertyseries.php">Language of Liberty</a></li>
<li><a href="#" onclick='window.open("newsletter/newsletter.pdf");return false;'>Newsletter</a></li>
<li><a href='#' class="login">Student Login</a>
</ul>

<nav>


CSS:

body {
margin: 0;
padding: 0;
height: 100%;
}

nav {
display:block;
position: absolute;
left:0;
white-space:nowrap;
margin: 0 auto;
width: 100%;
min-width: 900px;
max-width: 900px;
background-color:#0D4D8D;
padding-left: 15%;
padding-right: 38.1%;
}

nav ul {
display:block;
margin: 0 auto;
width: 100%;
list-style: none;
display: inline;
white-space:nowrap;
}

nav ul li {
float: left;
position: relative;
white-space:nowrap;
}

nav ul li a {
display: block;
margin: 0 auto;
width: auto;
padding: 0 10px 0 10px;
font-size: 14px;
font-family: "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
line-height: 44px;
text-align: center;
text-decoration: none;
color:white;
white-space:nowrap;
}

nav ul ul {
width: 200px;
position:absolute;
top:-99999px;
left:0;
opacity: 0;
-webkit-transition: opacity .4s ease-in-out;
-moz-transition: opacity .4s ease-in-out;
-o-transition: opacity .4s ease-in-out;
transition: opacity .4s ease-in-out;
z-index:497;
background:#333;
padding: 2px;
border:1px solid #444;
border-top:none;
box-shadow:#111 0 3px 4px;
}


nav ul ul li a {
display: block;
width: 200px;
text-align: left;
padding-left: 3px;
font-size: 14px;
}

nav ul li:hover>ul{
opacity: 1;
position:absolute;
top:98%;
left:0;
}

nav ul li a:hover {
color: #fff;
background-color: black;
}

nav ul li.selected a {
color: #fff;
background-color: black;
}


You can see it live here: Center for Self Governance

Answer

Hi now you add two css in your css file as like this

add your .class to position: relative; and z-index: 9999; and add your nav tag z-index: 99999; as like this

.class{position: relative;
    z-index: 9999;}

nav{z-index: 99999;}