I was wondering if it is possible to expand a div, that is positioned to be in the center by using justify-content: center;
and align-items: center;
only from below when new Elements are added to it.
const items = document.getElementById('items');
const add = () => {
const newItem = document.createElement('div');
newItem.innerText = 'Item';
items.append(newItem);
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
#body{
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
}
#container{
background-color: whitesmoke;
min-height: 200px;
width: 200px;
}
<div id="body">
<div id="container">
<button onClick='add()'>Add item</button>
<div id="items"></div>
</div>
</div>
As you can see, the elements make it expand from above and below. What I want it to do is only expand from below.