0

I have this navigation links and upon hovering the last link (styled as button), I want it to have a property of bottom border of color pink instead of brown upon hover to complement the color red button. Your help is appreciated. Thanks in advance!

.header-nav a:hover {
    border-bottom: 5px solid rgb(56,47,50); /*brown border-bottom*/
}

.header-nav a:last-of-type:hover {
    border-bottom: 5px solid rgb(255,144,171); /*pink-border-bottom*/
} 

        <nav class="container header-nav">
            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#cupcakes">Cupcakes</a></li>
                <li><a href="#cakes">Cakes</a></li>
                <li><a href="#events">Events</a></li>
                <li><a href="#contacts" class="btn nav-btn">Order Now!</a></li>
            </ul>
            <br>
        </nav>

Here's the fiddle: https://jsfiddle.net/ssqLspsn/

Ly18
  • 3
  • 3

5 Answers5

1

I DID IT!!! Look here https://jsfiddle.net/Please_Reply/9hk6okpd/2/ hope this is what you want!!!

.header-nav a:hover {
    border-bottom: 5px solid rgb(56,47,50); /*brown border-bottom*/
}

.header-nav .btn:hover {
    border-bottom: 5px solid rgb(255,144,171); /*pink-border-bottom*/
} 
nobodyshere
  • 208
  • 1
  • 5
1

Try to put some class to the button (last element) You css is fine although

like

<div class="header-nav">
<a>some text</a>
<a>some text</a>
<a class="btn">some text</a>
</div>

css

header-nav .btn:hover {
    border-bottom: 5px solid rgb(255,144,171); /*pink-border-bottom*/
}

If you want to keep your css selectors, you should select on li, not a Raplace .header-nav a:last-of-type:hover with .header-nav .li:last-child a:hover

Sergey Khmelevskoy
  • 2,429
  • 3
  • 19
  • 43
1

i DID IT!!! https://jsfiddle.net/Please_Reply/9hk6okpd/2/ hope this is what you want!!!

.header-nav a:hover {
    border-bottom: 5px solid rgb(56,47,50); /*brown border-bottom*/
}

.header-nav .btn:hover {
    border-bottom: 5px solid rgb(255,144,171); /*pink-border-bottom*/
} 
nobodyshere
  • 208
  • 1
  • 5
0

maybe you will put id or class name for last li and make css code the specific id :)

ahe
  • 21
  • 4
  • i did that already but it doesn't work (same property being applied). specificity sucks. kidding! just a newbie here. – Ly18 Jul 09 '16 at 11:20
0

The best thing to do when checking which css is applied on hover is to have the hover attribute active from the console. You can do this both in firefox and chrome by going to the inspector. Here is the guide to seeing how to activate the hover attribute See :hover state in Chrome Developer Tools

As for your specific problem it would help if you also posted your html, because css will not work if you're applying the style to a wrong element.

.header-nav li:hover {
    border-bottom: 5px solid rgb(56,47,50); /*brown border-bottom*/
}

.header-nav li:last-of-type:hover {
    border-bottom: 5px solid rgb(255,144,171); /*pink-border-bottom*/
} 

Good Luck!

Community
  • 1
  • 1
Isabel Inc
  • 1,871
  • 2
  • 21
  • 28