Dejan.S Dejan.S - 7 months ago 27
HTML Question

Nested flexbox, align-items do not flex-end

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-itcems: flex-end;
}
a {
text-decoration: none;
display: block;
padding: 1em;
color: white;
}
}
.search {
background: #fff;
flex: 12%;
}
}

Answer

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

Comments