Hover not working on navigation menu text
up vote
0
down vote
favorite
I have a navigation bar with 5 items. Hover only works when mouse moves over the whole item, but doesn't work when on the items' text. It happened after I changed the size of navigation bar. Here is my CSS code.
ul {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
list-style-type: none;
margin: 0;
padding: 0;
height: 40px;
overflow: hidden;
background-color: #212121;
}
li {
float: left;
height: 40px;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 12px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: red;
}
.dropdown-content a:hover {
background-color: #00ccff;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.dropdown:hover .dropdown-content {
display: block;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
<div id="oes_navigationbar">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a class="selected" href="../Views/loginpage.jsp">Login</a></li>
<li><a href="../Views/about.jsp">About</a></li>
<li class="dropdown"><a href="#" class="dropbtn">Sign Up</a>
<div class="dropdown-content"><a href="../Student/registrationpage.jsp">As Student</a><a href="../faculty/facultyregistration.jsp">As Faculty</a></div>
</li>
<li><a href="../Views/contactpage.jsp" target="_blank">Contact</a></li>
<li><a href="../Views/help.jsp" target="_blank">Help</a></li>
</ul>
<div class="cleaner"></div>
</div>
html css hover navigationbar onhover
|
show 1 more comment
up vote
0
down vote
favorite
I have a navigation bar with 5 items. Hover only works when mouse moves over the whole item, but doesn't work when on the items' text. It happened after I changed the size of navigation bar. Here is my CSS code.
ul {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
list-style-type: none;
margin: 0;
padding: 0;
height: 40px;
overflow: hidden;
background-color: #212121;
}
li {
float: left;
height: 40px;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 12px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: red;
}
.dropdown-content a:hover {
background-color: #00ccff;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.dropdown:hover .dropdown-content {
display: block;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
<div id="oes_navigationbar">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a class="selected" href="../Views/loginpage.jsp">Login</a></li>
<li><a href="../Views/about.jsp">About</a></li>
<li class="dropdown"><a href="#" class="dropbtn">Sign Up</a>
<div class="dropdown-content"><a href="../Student/registrationpage.jsp">As Student</a><a href="../faculty/facultyregistration.jsp">As Faculty</a></div>
</li>
<li><a href="../Views/contactpage.jsp" target="_blank">Contact</a></li>
<li><a href="../Views/help.jsp" target="_blank">Help</a></li>
</ul>
<div class="cleaner"></div>
</div>
html css hover navigationbar onhover
2
where is your html? provide a working example (not just code blocks).
– Dekel
Nov 19 at 14:24
I don't see any dropdown in your example
– Dekel
Nov 19 at 14:34
ul {overflow: hidden;}
hides the dropdown
– Simsteve7
Nov 19 at 14:35
Can you describe the problem more? If I remove the overflow of ul, the dropdown works ok. Also addul:after {clear: both; content: ''; display: block;}
and remove height ofli
andul
, move it to thea
.
– Simsteve7
Nov 19 at 14:40
dropdown used only fordisplay: inline-block
– Dev Sharma
Nov 19 at 14:46
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a navigation bar with 5 items. Hover only works when mouse moves over the whole item, but doesn't work when on the items' text. It happened after I changed the size of navigation bar. Here is my CSS code.
ul {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
list-style-type: none;
margin: 0;
padding: 0;
height: 40px;
overflow: hidden;
background-color: #212121;
}
li {
float: left;
height: 40px;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 12px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: red;
}
.dropdown-content a:hover {
background-color: #00ccff;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.dropdown:hover .dropdown-content {
display: block;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
<div id="oes_navigationbar">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a class="selected" href="../Views/loginpage.jsp">Login</a></li>
<li><a href="../Views/about.jsp">About</a></li>
<li class="dropdown"><a href="#" class="dropbtn">Sign Up</a>
<div class="dropdown-content"><a href="../Student/registrationpage.jsp">As Student</a><a href="../faculty/facultyregistration.jsp">As Faculty</a></div>
</li>
<li><a href="../Views/contactpage.jsp" target="_blank">Contact</a></li>
<li><a href="../Views/help.jsp" target="_blank">Help</a></li>
</ul>
<div class="cleaner"></div>
</div>
html css hover navigationbar onhover
I have a navigation bar with 5 items. Hover only works when mouse moves over the whole item, but doesn't work when on the items' text. It happened after I changed the size of navigation bar. Here is my CSS code.
ul {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
list-style-type: none;
margin: 0;
padding: 0;
height: 40px;
overflow: hidden;
background-color: #212121;
}
li {
float: left;
height: 40px;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 12px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: red;
}
.dropdown-content a:hover {
background-color: #00ccff;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.dropdown:hover .dropdown-content {
display: block;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
<div id="oes_navigationbar">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a class="selected" href="../Views/loginpage.jsp">Login</a></li>
<li><a href="../Views/about.jsp">About</a></li>
<li class="dropdown"><a href="#" class="dropbtn">Sign Up</a>
<div class="dropdown-content"><a href="../Student/registrationpage.jsp">As Student</a><a href="../faculty/facultyregistration.jsp">As Faculty</a></div>
</li>
<li><a href="../Views/contactpage.jsp" target="_blank">Contact</a></li>
<li><a href="../Views/help.jsp" target="_blank">Help</a></li>
</ul>
<div class="cleaner"></div>
</div>
ul {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
list-style-type: none;
margin: 0;
padding: 0;
height: 40px;
overflow: hidden;
background-color: #212121;
}
li {
float: left;
height: 40px;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 12px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: red;
}
.dropdown-content a:hover {
background-color: #00ccff;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.dropdown:hover .dropdown-content {
display: block;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
<div id="oes_navigationbar">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a class="selected" href="../Views/loginpage.jsp">Login</a></li>
<li><a href="../Views/about.jsp">About</a></li>
<li class="dropdown"><a href="#" class="dropbtn">Sign Up</a>
<div class="dropdown-content"><a href="../Student/registrationpage.jsp">As Student</a><a href="../faculty/facultyregistration.jsp">As Faculty</a></div>
</li>
<li><a href="../Views/contactpage.jsp" target="_blank">Contact</a></li>
<li><a href="../Views/help.jsp" target="_blank">Help</a></li>
</ul>
<div class="cleaner"></div>
</div>
ul {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
list-style-type: none;
margin: 0;
padding: 0;
height: 40px;
overflow: hidden;
background-color: #212121;
}
li {
float: left;
height: 40px;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 12px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: red;
}
.dropdown-content a:hover {
background-color: #00ccff;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.dropdown:hover .dropdown-content {
display: block;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
<div id="oes_navigationbar">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a class="selected" href="../Views/loginpage.jsp">Login</a></li>
<li><a href="../Views/about.jsp">About</a></li>
<li class="dropdown"><a href="#" class="dropbtn">Sign Up</a>
<div class="dropdown-content"><a href="../Student/registrationpage.jsp">As Student</a><a href="../faculty/facultyregistration.jsp">As Faculty</a></div>
</li>
<li><a href="../Views/contactpage.jsp" target="_blank">Contact</a></li>
<li><a href="../Views/help.jsp" target="_blank">Help</a></li>
</ul>
<div class="cleaner"></div>
</div>
html css hover navigationbar onhover
html css hover navigationbar onhover
edited Nov 19 at 14:30
Pugazh
8,04841942
8,04841942
asked Nov 19 at 14:23
Dev Sharma
269
269
2
where is your html? provide a working example (not just code blocks).
– Dekel
Nov 19 at 14:24
I don't see any dropdown in your example
– Dekel
Nov 19 at 14:34
ul {overflow: hidden;}
hides the dropdown
– Simsteve7
Nov 19 at 14:35
Can you describe the problem more? If I remove the overflow of ul, the dropdown works ok. Also addul:after {clear: both; content: ''; display: block;}
and remove height ofli
andul
, move it to thea
.
– Simsteve7
Nov 19 at 14:40
dropdown used only fordisplay: inline-block
– Dev Sharma
Nov 19 at 14:46
|
show 1 more comment
2
where is your html? provide a working example (not just code blocks).
– Dekel
Nov 19 at 14:24
I don't see any dropdown in your example
– Dekel
Nov 19 at 14:34
ul {overflow: hidden;}
hides the dropdown
– Simsteve7
Nov 19 at 14:35
Can you describe the problem more? If I remove the overflow of ul, the dropdown works ok. Also addul:after {clear: both; content: ''; display: block;}
and remove height ofli
andul
, move it to thea
.
– Simsteve7
Nov 19 at 14:40
dropdown used only fordisplay: inline-block
– Dev Sharma
Nov 19 at 14:46
2
2
where is your html? provide a working example (not just code blocks).
– Dekel
Nov 19 at 14:24
where is your html? provide a working example (not just code blocks).
– Dekel
Nov 19 at 14:24
I don't see any dropdown in your example
– Dekel
Nov 19 at 14:34
I don't see any dropdown in your example
– Dekel
Nov 19 at 14:34
ul {overflow: hidden;}
hides the dropdown– Simsteve7
Nov 19 at 14:35
ul {overflow: hidden;}
hides the dropdown– Simsteve7
Nov 19 at 14:35
Can you describe the problem more? If I remove the overflow of ul, the dropdown works ok. Also add
ul:after {clear: both; content: ''; display: block;}
and remove height of li
and ul
, move it to the a
.– Simsteve7
Nov 19 at 14:40
Can you describe the problem more? If I remove the overflow of ul, the dropdown works ok. Also add
ul:after {clear: both; content: ''; display: block;}
and remove height of li
and ul
, move it to the a
.– Simsteve7
Nov 19 at 14:40
dropdown used only for
display: inline-block
– Dev Sharma
Nov 19 at 14:46
dropdown used only for
display: inline-block
– Dev Sharma
Nov 19 at 14:46
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376663%2fhover-not-working-on-navigation-menu-text%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
where is your html? provide a working example (not just code blocks).
– Dekel
Nov 19 at 14:24
I don't see any dropdown in your example
– Dekel
Nov 19 at 14:34
ul {overflow: hidden;}
hides the dropdown– Simsteve7
Nov 19 at 14:35
Can you describe the problem more? If I remove the overflow of ul, the dropdown works ok. Also add
ul:after {clear: both; content: ''; display: block;}
and remove height ofli
andul
, move it to thea
.– Simsteve7
Nov 19 at 14:40
dropdown used only for
display: inline-block
– Dev Sharma
Nov 19 at 14:46