I have a div that has text that is right aligned. I want to then center that div within its parent.
The code below only applies the right-alignment.
CSS
.outerDiv {
text-align: center;
width: 100%;
}
.innerDiv {
text-align: right;
width: auto;
}
HTML
<div class="outerDiv">
<div class="innerDiv">
10<br/>
<span style="border-bottom: 1px solid black">
+ 2
</span><br />
12
</div>
</div>
I know this can be done with using margin-left: auto; margin-right: auto
in the outer div, but that requires that you set the inner div's width, which I don't know ahead of time.
Ideas?