skip to Main Content

I want to have a big red “Donate” button with white text in the navber, and my solution was <a href="#" class="btn btn-danger">Donate Now</a>. However, the button seems to turn transparent on hover.

I’ve also tried <span class="label label-danger">Danger</span> and <p class="btn btn-danger">Donate Now</p>, but the former is too small, while the latter seems strange on hover.

<head>
  <title>
    Test
  </title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!-- Bootstrap -->
  <link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  <link href="/static/knowledge/index.css" rel="stylesheet">
</head>

<body>
  <div class="header">
    <nav class="navbar navbar-default navbar-static-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
            <li>
              <a href="#" class="btn btn-danger">Donate Now</a>
            </li>
          </ul>
        </div>
        <!--/.nav-collapse -->
      </div>
    </nav>
  </div>
</body>

In case my problem cannot be reproduced by the code above, I also created this fiddle.

3

Answers


  1. Try this code on your custom style sheet

    .navbar-default .navbar-nav>li>a:focus, .navbar-default .navbar-nav>li>a:hover {
        color: #333;
        background-color: red!important;
        border: 1px solid red!important;
    }
    
    Login or Signup to reply.
  2. try this may be this will help you

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>Bootstrap Case</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
      <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    <body>
    
    <nav class="navbar navbar-inverse">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>                        
          </button>
          <a class="navbar-brand" href="#">WebSiteName</a>
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
          <ul class="nav navbar-nav">
           <p class="btn btn-danger btn-lg">Donate Now</p>
          </ul>
        </div>
      </div>
    </nav>
      
    <div class="container">
      <h3>Collapsible Navbar</h3>
      <p>In this example, the navigation bar is hidden on small screens and replaced by a button in the top right corner (try to re-size this window).
      <p>Only when the button is clicked, the navigation bar will be displayed.</p>
    </div>
    
    </body>
    </html>
    Login or Signup to reply.
  3. You’ve used a label in your fiddle instead of a button. And you’re not supposed to use buttons where a Navigation link belongs, but you’re able to bypass this with a simple wrapper.

    <li>
        <span>
           <a class="btn btn-danger btn-lg">Donate Now</a>
        </span>
    </li>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search