I have one container with flexible width (100%) and block elements inside which are dynamically added.
<div class="main">
<div class="block-element">
<span>element1</span>
<div>
text1<br>
text2
</div>
</div>
<div class="block-element">
<span>element2</span>
<div>
text1<br>
text2
</div>
</div>
</div>
.main {
display: flex;
justify-content: center;
overflow: scroll;
width: 100%;
}
.block-element {
display: flex;
align-items: center;
border: 1px solid blue;
padding: 5px;
margin-left: 20px;
}
The problem is to keep elements inside container centered and to make container scrollable when size of its block elements become larger then size of container.
The main problem is that I can keep elements centered only with flexbox, but in that case scrollable content on the left side is cut (well known problem with flex layout).
What ever I did one problem remain. Working example is here: https://jsfiddle.net/kypLg2cm/3/
Example 2 shows how content is cut off on the left side.