I found a much easier way to do this by accident. Say you have the following:
You can align Some text 1
and Some text 2
using css table display styling like this:
.a {
display: table-row;
}
.a div {
display: table-cell;
}
The coolest thing is that as long as the 'top' div is NOT styled display: table
, then other things like "Something else" can be ignored in terms of alignment. If the 'top' div IS styled display: table
, then "Some text 1" will be aligned with "Something else" (ie it treats all its children like table rows, even if they have a different display style).
This works in Chrome, not sure if its supposed to behave this way, but I'm glad it works.
.a {
display: table-row;
}
.a div {
display: table-cell;
}