As you can see in the snippet below, the dots under foo-wrapper
do not follow the vertical alignment of the text labels under bar-wrapper
. But I was expecting this, as per the :nth-child(i)
rules.
How can I make the dots, which are the children of a different container which is subsequently a child of a horizontal flexbox (the parent-wrapper
), follow the vertical alignment of the children from the other container?
Do I have to renounce flexbox altogether and use something like the grid layout?
<!DOCTYPE html>
<head>
<style>
.parent-wrapper {
align-items: stretch;
display: flex;
flex-flow: row nowrap;
height: 256px;
width: 100%;
}
.foo-wrapper {
background-color: orange;
margin: 1.5rem;
width: 2px;
}
.dot {
background-color: #ebf0ff;
border-radius: 0.5rem;
height: 1rem;
width: 1rem;
}
.foo-wrapper div:nth-child(1) {
margin-top: 1rem;
}
.foo-wrapper div:nth-child(2) {
margin-top: 1rem;
}
.foo-wrapper div:nth-child(3) {
margin-top: 1rem;
}
.bar-wrapper {
border: 1px solid green;
display: flex;
flex-flow: column nowrap;
margin: 1.5rem;
flex-grow: 1;
}
.bar-wrapper div:nth-child(1) {
margin-top: 1rem;
}
.bar-wrapper div:nth-child(2) {
margin-top: 2rem;
}
.bar-wrapper div:nth-child(3) {
margin-top: 4rem;
}
</style>
</head>
<body>
<div class="parent-wrapper">
<div class="foo-wrapper">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
<div class="bar-wrapper">
<div>Lorem</div>
<div>ipsum</div>
<div>dolores</div>
</div>
</div>
</body>