-1

Im Trying to center my links right under the h1, but nothing works. Here's what i have right now, i would love any help or pointers! This is my h1-tag

<div class="container-fluid p-5 bg-success header-body text-center">
  <h1 id="high-credit-top-text">
    <a class="text-white" style="font-family: 'Lexend Deca', sans-serif;" href="hogkostnadskredit.php">Playaround.se</a>
  </h1>

<nav class="navbar navbar-expand-lg navbar-light bg-success">
  <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">
      <div class="container justify-content-center">
        <ul class="navbar-nav">
          <li class="nav-item active">
            <a class="nav-link text-white" href="playaround.php"><i class="fas fa-home"></i></a>
          </li>
          <li class="nav-item">
            <a class="nav-link text-white" href="nyheter.php">Nyheter</a>
          </li>
          <li class="nav-item">
            <a class="nav-link text-white" href="information.php">Infomartion</a>
          </li>
        </ul>
      </div>
    </div>
</nav>

1 Answers1

0

If you are trying to center the .nav-item links horizontally, then add the bootstrap class justify-content-center to the ul tag with class navbar-nav

<ul class="navbar-nav justify-content-center">
  <li class="nav-item active">
    <a class="nav-link text-white" href="playaround.php"><i class="fas fa-home"></i></a>
  </li>
  <li class="nav-item">
    <a class="nav-link text-white" href="nyheter.php">Nyheter</a>
  </li>
  <li class="nav-item">
    <a class="nav-link text-white"         href="information.php">Infomartion</a>
  </li>
</ul>

Example

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="container-fluid p-5 bg-success header-body text-center">
  <h1 id="high-credit-top-text">
    <a class="text-white" style="font-family: 'Lexend Deca', sans-serif;" href="hogkostnadskredit.php">Playaround.se</a>
  </h1>
</div>

<nav class="navbar navbar-expand-lg navbar-light bg-success">
  <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">
    <div class="container justify-content-center">
      <ul class="navbar-nav justify-content-center">
        <li class="nav-item active">
          <a class="nav-link text-white" href="playaround.php"><i class="fas fa-home"></i></a>
        </li>
        <li class="nav-item">
          <a class="nav-link text-white" href="nyheter.php">Nyheter</a>
        </li>
        <li class="nav-item">
          <a class="nav-link text-white" href="information.php">Infomartion</a>
        </li>
      </ul>
    </div>
  </div>
</nav>
Soothran
  • 1,233
  • 4
  • 14