Comment créer une barre de navigation avec un compteur de notification à l'aide de bootstrap 4 ?

Active 24 février 2021    /    Viewed 875    /    Comments 0    /    Edit


Exemples de comment créer une barre de navigation avec un compteur de notification à l'aide de bootstrap 4

Exemple 1

Code

<span class="badge badge-pill badge-warning" style="float:right;margin-bottom:-15px;margin-right:-18px;font-size:10px">123</span>
<a class="nav-link" href="/News/">News <span class="sr-only">(current)</span></a>

Comment créer une barre de navigation avec un compteur de notification à l'aide de bootstrap 4 ?

Code complet

<!DOCTYPE html>
<html lang="en">

<head>

<title>Test</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

</head>

<body>

<nav class="navbar navbar-expand-lg navbar-default fixed-top navbar-dark" style="background-color: #3c3d41;" id="mainNav">

  <div class="container">

      <a class="navbar-brand" href="/" style="color:white">Hello World</a>

      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="collapsibleNavbar">
        <ul class="navbar-nav">    
            <li class="nav-item">
                <span class="badge badge-pill badge-warning" style="float:right;margin-bottom:-15px;margin-right:-18px;font-size:10px">123</span>
                <a class="nav-link" href="/News/">News <span class="sr-only">(current)</span></a>
            </li>         
        </ul>
      </div>

</div>
</nav>


</body>
</html>

Exemple 2

Changer la couleur:

badge-danger

How to create a navbar with a notification counter using bootstrap 4 ?

badge-info

How to create a navbar with a notification counter using bootstrap 4 ?

Références


Card image cap
profile-image
Daidalos

Hi, I am Ben.

I have developed this web site from scratch with Django to share with everyone my notes. If you have any ideas or suggestions to improve the site, let me know ! (you can contact me using the form in the welcome page). Thanks!