Put bar in the Bootstrap menu

2

I want to put a bar in the menu as shown below:

  

Home | Instructor Course | Legal Advice

For this I am using the code below:

<div class="row">
        <nav class="navbar navbar-expand-lg navbar-light">
          <a class="navbar-brand" href="#">&nbsp;</a>
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
              <li class="nav-item active">
                <a class="nav-link" href="#">Principal</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Curso de Instrutor</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Assessoria Jurídica</a>
              </li>
            </ul>
          </div>
        </nav>
      </div>

And in CSS:

ul li
{
    display: inline;
}

li:before {
content: " | ";
}

li:first-child:before {
content: none;
}

It's just like this:

How can I fix this?

    
asked by anonymous 14.11.2018 / 21:57

2 answers

2

You can create the bar with a span for example and stylize it until you get the expected result:

.linha-vertical {
  border-left: 2px solid;
  box-sizing: border-box;
  margin: 10px 10px 0 10px;
  height: 20px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">

<div class="row">
  <nav class="navbar navbar-expand-lg navbar-light">
    <a class="navbar-brand" href="#">&nbsp;</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav">
        <li class="nav-item active">
          <a class="nav-link" href="#">Principal</a>
        </li>
        <span class="linha-vertical"></span>
        <li class="nav-item">
          <a class="nav-link" href="#">Curso de Instrutor</a>
        </li>
        <span class="linha-vertical"></span>
        <li class="nav-item">
          <a class="nav-link" href="#">Assessoria Jurídica</a>
        </li>
      </ul>
    </div>
  </nav>
</div>
    
14.11.2018 / 22:18
0

<!DOCTYPE html>
<html lang="pt">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script></head><body><navclass="navbar navbar-expand-sm bg-dark navbar-dark">
  
  <!-- Links -->
  <ul class="navbar-nav">
    <li class="nav-item">
      <a class="nav-link" href="#">Principal</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">Curso de Instrutor</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">Assessoria Jurídica</a>
    </li>
  </ul>
</nav>


</body>
</html>
    
14.11.2018 / 23:37