1

I'm trying to place the navigation at the bottom with flex-end. I'm not sure what's causing it not to place at the bottom. I know I can place it with position absolute, trying to avoid that.

code is on jsfiddle

<header>
  <div class="header__logo">
    <a href=""></a>
  </div>
  <nav>
    <ul>
      <li><a href="#">one</a></li>
      <li><a href="#">two</a></li>
      <li><a href="#">three</a></li>
      <li><a href="#">four</a></li>
    </ul>
  </nav>
  <div class="search"></div>
</header>

header {
  background: deepskyblue;
  display: flex;
  padding: 20px 0;
  .header__logo {
    background: aqua;
    flex: 20%;
    min-height: 140px;
  }
  nav {
    background: #111;
    flex: 78%;
    ul {
      list-style: none;
      margin: 0;
      background: aquamarine;
      display: flex;
      justify-content: flex-end;
            align-items: flex-end;
    }
    a {
      text-decoration: none;
      display: block;
      padding: 1em;
      color: white;
    }
  }
  .search {
    background: #fff;
    flex: 12%;
  }
}
Dejan.S
  • 18,571
  • 22
  • 69
  • 112

1 Answers1

2

In your code, you're not actually placing the nav at the bottom with align-items:flex-end. You're placing the list items at the bottom of the ul.

Except the ul container has no added height, so the list items don't go anywhere:

demo with height added

To bottom-align the nav, give it an align-self: flex-end, so it aligns within the larger flex container.

revised fiddle

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
  • 1
    I totally missed the property `align-self: flex-end;` thanks for that. – Dejan.S Apr 27 '16 at 20:37
  • 1
    `margin-top: auto` on the `nav` would also work: https://jsfiddle.net/oxreqng0/4/ ... ([more about `auto` margins](http://stackoverflow.com/a/33856609/3597276)) – Michael Benjamin Apr 27 '16 at 20:50