Bipul Roy
Bipul Roy

Reputation: 566

Can not style the navbar links bootstrap

Here is the html

<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#homenavbar">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a href="home.html" class="navbar-brand" style="padding-top: 0;margin-top: 0">Name</a>
    </div>
    <div class="collapse navbar-collapse" id="homenavbar">
        <ul class="nav navbar-nav pull-right hidden-xs hidden-sm" id="menu">
            <li><a href="#home">HOME</a></li>
            <li><a href="#about">ABOUT</a></li>
            <li><a href="#services">SERVICES</a></li>
            <li><a href="#portfolio">PORTFOLIO</a></li>
            <li><a href="#testimonial">TESTIMONIAL</a></li>
            <li><a href="#contact">CONTACT</a></li>
        </ul>
    </div>
</div>
</nav>`

Here is the css

.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
border-bottom: 3px solid green;
color: #009ddc;
}

but hover and focus are not working.I couldn't find the problem. Anyone please help.

Upvotes: 0

Views: 80

Answers (2)

Gari
Gari

Reputation: 54

#menu li > a:hover, #menu li:hover >a{
  color:red;
  }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
  
        <ul class="nav navbar-nav pull-right" id="menu">
            <li><a href="#home">HOME</a></li>
            <li><a href="#about">ABOUT</a></li>
            <li><a href="#services">SERVICES</a></li>
            <li><a href="#portfolio">PORTFOLIO</a></li>
            <li><a href="#testimonial">TESTIMONIAL</a></li>
            <li><a href="#contact">CONTACT</a></li>
        </ul>
    </div>
</div>
</nav>

Try this :) If you mind to do "active class" do with javascript

Upvotes: 1

Matthew Beckman
Matthew Beckman

Reputation: 1722

With the exception of the closing </nav> tag, your code is correct. I've copied and pasted your code into a JSFiddle, and the hover works fine.

Upvotes: 0

Related Questions