Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJonny Strange
6,412 PointsHover not working on mobile navigation menu
I'm designing a online portfolio of myself but the :hover isn't working when the mouse is hovering over the mobile navigation menu links. ;hover is working everywhere else. My test site's http://www.jstrange.co.uk/testsite/index.html
3 Answers
thomascawthorn
22,986 PointsAh I've got it.
ID's have higher priority than classes.
This:
#main-menu li a
{
background: #fff;
}
is overriding this:
.mobile-menu li a:hover {
background: #ac5104;
}
even when hovered.
try this:
#main-menu.mobile-menu li a:hover {
background: #ac5104;
}
thomascawthorn
22,986 PointsCan you copy in the particular bit of css that isn't working?
Also the html of JUST that button :-)
Jonny Strange
6,412 Pointshtml:
<a class="mobile-menu-toggle" id="mobile-nav-trigger" href="#">
<i class="fa fa-bars"></i>
</a>
<ul class="mobile-menu mobile-menu-closed" id="main-menu">
<li class="selected"><a href="#personal-profile">Personal Profile</a></li>
<li><a href="#skills">Skills</a></li>
<li><a href="#work-experience">Work Experience</a></li>
<li><a href="#education">Education</a></li>
<li><a href="#portfolio">Portfolio</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
css:
#navigation
{
height: 3.4em;
width: 100%;
padding: 0;
margin: 0 0 2em 0;
border-top: 1px solid #AC5104;
border-bottom: 1px solid #AC5104;
}
#main-nav,
.mobile-menu
{
width: 8.4em;
padding: 0;
list-style-type: none;
}
.selected
{
}
#main-menu li
{
width: 8.4em;
margin: 0 0 0 0;
padding: 0;
background-color: #fff;
}
#main-menu li a
{
background: #fff;
}
/* Mobile */
#mobile-nav-trigger
{
position: absolute;
margin: -1.6em 0 0 6.6em;
font-size: 2rem;
padding: 0.2em;
border: 1px solid #0f0d0d;
}
.mobile-menu
{
position: absolute;
margin: 0.1em 0 0 7.3em;
text-align: center;
border: 1px solid #0f0d0d;
z-index: 2;
}
.mobile-menu-closed
{
display: none;
}
/*****************************************************************
NAVIGATION ACHORS STYLES
******************************************************************/
a,
a:link {color: #0f0d0d;}
a:visited {color: #867e31;}
a:hover {background: #ac5104; color: #0f0d0d;}
.mobile-menu:hover {background: #ac5104; color: #0f0d0d;}
.mobile-menu li:hover {background: #ac5104; color: #0f0d0d;}
.mobile-menu li a:hover {background: #ac5104;}
.back-to-top {margin-left: 12.6em; color: #0f0d0d;}
thomascawthorn
22,986 PointsTry declaring a :link, :visisted and:hover for .mobile-menu.
I notice you've left out :link and :visited - you've only declared them on 'a'
Jonny Strange
6,412 PointsI've tied that but it still isn't working. Any more ideas??
Jonny Strange
6,412 PointsJonny Strange
6,412 PointsThanks Tom it's working now.