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 trial

CSS

Adding a line under menu items on current item and on hover

Hi all,

A bit of a noob question.

I'm currently working on customising a theme, and am trying to change the look of the main menu. It currently displays a solid colour background behind both the current page title in the menu, and behind other menu items on hover. You can see it here:

http://lindsayclarke.com

I need to change both instances to a coloured line underneath the menu items (and remove the coloured background).

This image shows the effect we need:

https://dl.dropboxusercontent.com/u/4013946/LindsayClarke_website_041113-Blog.jpg

I imagine you would use something like:

border-bottom: 2px #f62e9b

Would this be on the right track? I also for the life of me can't figure out what section of CSS is controlling the current page and hover menu functionality.

If anyone can point me in the right direction, it would be appreciated.

Thanks all.

Tim

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

You can do something like the below.

.sf-menu li:hover,
.sf-menu li.sfHover,
.sf-menu li.current-menu-item {
    background: none;
    border-bottom: 2px solid #f62e9b;
}

To keep the animation you can change the following

.sf-menu li {
    -webkit-transition: background .2s;
    transition: background .2s;
}

to

.sf-menu li {
    -webkit-transition: border .2s;
    transition: border .2s;
}