I need to center(left to right) absolute elements(green) inside a relative container(blue). The child elements(green) need to have a dynamic/unset width. I would rather not use JavaScript(CSS and html only).
Code:
.relativeParent {
width: 100px;
height: 100px;
background: blue;
position: relative;
overflow: visible;
display: block;
margin-left: 100px;
margin-bottom: 20px;
}
.absoluteChild {
display: block;
background: green;
position: absolute;
}
<div class="App">
<div class='relativeParent'>
<div class='absoluteChild'>test</div>
</div>
<div class='relativeParent'>
<div class='absoluteChild'>asd asdf asdf asdf asdfa sdf</div>
</div>
</div>