I'd like to use a relative div
to fill it up with inline-block
-elements aligned next to each other that all got the same width & same height (= squares).
So if there are n
elements the relative div
should get scrollable in x-direction. This is working so far as you can see in the example code below:
.outer {
position: absolute;
width: 100%;
height: 100%;
}
.parent {
position: relative;
width: 90%;
height: 40%;
overflow-y: hidden;
overflow-x: scroll;
text-align: center;
white-space: nowrap;
background: red;
}
.item {
background: yellow;
display: inline-block;
width: 4%;
margin: 0% 3%;
}
.item::after {
content: "";
display: block;
padding-bottom: 100%;
}
<div class="outer">
<div class="parent">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</div>
But now I'd like the item
-elements (yellow squares) to vertical align into the red parent-div
(relative div) so that the distance from top to center and from bottom to center is identical. Please have a look at this image:
Note: I do not want to change the hierarchy (keep the parent elem relative & the outer elem absolute, etc...)
How can I achieve this?