I need horizontal center align an flexible width div
element.
<div class="outer">
<div class="inner"> ...this content will grow or shrink while on items changed... </div>
</div>
.outer {
height: 500px;
position: relative;
background-color: gray;
}
.inner {
position: absolute;
left: 50%;
bottom: 10px;
transform: translateX(-50%);
border: 1px solid blue;
}
As you can see the div.inner
is perfectly horizontal center aligned, but its max width will always be 50% of the div.outer
while I hope the max width could be more when the content is grown.
And:
- I don't want to give
div.inner
a fixed or min with, I hope it's flexible; - I know "max-width" does not work
Any suggestion will be appreciated!