This issue is weird, acts differently on normal containers and flexbox.
Changing the font-size
of the FIRST children:
- for NORMAL CONTAINER, why is it changing the container's height?
- for FLEXBOX, why is it making the flexbox move down or up for some distance?
How do I resolve this? I want the FLEXBOX not to move.
To be said, it's only happening when changing font-size
of first children. Changing the second doesn't matter... why?
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #121212;
color: #fff;
font-size: 20px;
}
.container {
line-height: 48px;
font-size: 36px;
border: 1px solid #f90;
}
.first {
color: #ffe47e;
animation: change1 3s linear infinite;
}
@keyframes change1 {
0%,
100% {
font-size: 0.1em;
}
50% {
font-size: 1em;
}
}
@keyframes change2 {
0%,
100% {
font-size: 0.1em;
}
50% {
font-size: 2em;
}
}
.c2 {
display: inline-flex;
column-gap: 5px;
}
.c2 .first {
font-size: 0.5em;
animation: change2 3s linear infinite;
}
.c3 .first {
font-size: 0.5em;
animation: none;
}
<div style="margin-bottom: 50px;">
<div class="container c2 c3">
<span class="first">first</span>
Second
</div>
<div class="container c2 c3">
Second
<span class="first">This doesn't matter</span>
</div>
(flexbox) How to make the first flex container align with the second one?
</div>
<div style="margin-bottom: 50px;">
(flexbox) Animation illustration
<div class="container c2">
<span class="first">first</span>
Second
</div>
<div class="container c2">
Second
<span class="first">This doesn't matter</span>
</div>
</div>
(normal container) Animation illustration - Why is height changing?
<div class="container">
<span class="first">first</span>
Second
</div>