Francesco Casella
Francesco Casella

Reputation: 35

HTML and CSS fill all DIV

I have this nav-bar with icon: enter image description here

icons are at the center of the DIV, but what I want is to fill up all the DIV and then not have spaces left and right.

the DIV that contains it is this: enter image description here

mine is a REACT application and I also use bootstrap. I tried adding margin-left: 0 and margin right-right: 0, but that didn't work.

this is the HTML code

<nav class="navbar navbar-expand navbar-light bg-light fixed-bottom" style="padding-top: 0px; padding-bottom: 0px; width: 100%;">
   <div class="bottom-nav navbar-nav" style="height: 100%; margin: 0px auto;">
      <a href="#law" data-rb-event-key="#law" class="nav-icon fa-2x nav-link">
        ICON
      </a>
      <a href="#bar" data-rb-event-key="#bar" class="nav-icon fa-2x nav-link">
         ICON
      </a>
   </div>
</nav>

don't forget I use bootstrap, thank you.

can you help me? Thanks

Upvotes: 1

Views: 384

Answers (1)

Daniel Sixl
Daniel Sixl

Reputation: 2499

Just add a custom class and give your navigation full width. Your navigation has display: flex;. So you can use justify-content: space-between; to distribute your icons:

.custom-nav {
  justify-content: space-between;
  width: 100%;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js" integrity="sha256-KzZiKy0DWYsnwMF+X1DvQngQ2/FxF7MF3Ff72XcpuPs=" crossorigin="anonymous"></script>

<nav class="navbar navbar-expand navbar-light bg-light fixed-bottom" style="padding-top: 0px; padding-bottom: 0px; width: 100%;">
  <div class="bottom-nav navbar-nav custom-nav" style="height: 100%; margin: 0px auto;">
    <a href="#law" data-rb-event-key="#law" class="nav-icon fa-2x nav-link">
      <i class="fas fa-star"></i>
    </a>
    <a href="#bar" data-rb-event-key="#bar" class="nav-icon fa-2x nav-link">
      <i class="fas fa-glass-cheers"></i>
    </a>
    <a href="#restaurant" data-rb-event-key="#restaurant" class="nav-icon fa-2x nav-link">
      <i class="fas fa-utensils"></i>
    </a>
    <a href="#store" data-rb-event-key="#store" class="nav-icon fa-2x nav-link">
      <i class="fas fa-store"></i>
    </a>
  </div>
</nav>

Upvotes: 1

Related Questions