I’m having a bit of a problem. I’m using FireFox 3.6 and have the following DOM structure:
<div class="view-row">
<div class="view-type">Type</div>
<div class="view-name">Name</div>
</div>
And the following CSS:
.view-row {
width:100%;
display:table-row;
}
.view-name {
display: table-cell;
float:right;
}
.view-type {
display: table-cell;
}
If I take off the display:table-row it will appear correctly, with the view-row showing a width of 100%. If I put it back it shrinks down. I’ve put this up on JS Bin:
What’s going on?
If you’re using
display:table-rowetc., then you need proper markup, which includes a containing table. Without it your original question basically provides the equivalent bad markup of:Where’s the table in the above? You can’t just have a row out of nowhere (tr must be contained in either
table,thead,tbody, etc.)Instead, add an outer element with
display:table, put the 100% width on the containing element. The two inside cells will automatically go 50/50 and align the text right on the second cell. Forgetfloatswith table elements. It’ll cause so many headaches.markup:
CSS: