Im playing around with the flex property and position and I have discovered something.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
}
.mainContainer {
margin: 10vh auto;
width: 80vh;
height: 80vh;
/* display: flex; */
justify-content: center;
/* align-items: center; */
border: 1px solid red;
/* position: relative; */
}
.alterContainer {
position: absolute;
/* z-index: 1; */
/* top: 0; */
align-self: center;
width: 50vh;
height: 50vh;
background-color: #ccc;
border: 1px solid green;
}
.alterContainer1 {
position: absolute;
align-self: center;
/* top: 0; */
/* z-index: 1; */
/* top: 0; */
width: 25vh;
height: 25vh;
border: 1px solid green;
}
<div class="mainContainer">
<div class="alterContainer"></div>
<div class="alterContainer1"></div>
</div>
Thats the code.
I´ve noticed that when positioning a child position:absolute;
and its parent is display: flex
what happens is that the child is like the only element in the parent. It goes out-of-flow, it does not "interact" with the other flex-childs.
When positioned absolute, the flex values given to the parent AFFECT this child, on his own.
Anyone has more info about this?
Thanks