I have an MVC3 view as follows:
<div id="table">
@Html.DisplayForModel()
</div>
which renders as follows:
<div id="table">
<div class="display-label">Label 1</div>
<div class="display-field">Value 1</div>
<div class="display-label">Label 2</div>
<div class="display-field">Value 2</div>
... etc ...
<div class="display-label">Label n</div>
<div class="display-field">Value n</div>
</div>
Is there a pure CSS way of making this into a tabular layout - the equivalent of:
<table>
<tr><td>Label 1</td><td>Value 1</td>
<tr><td>Label 2</td><td>Value 2</td>
<tr><td>Label 3</td><td>Value 3</td>
<tr><td>Label 4</td><td>Value 4</td>
</table>
Or failing that, a CSS + jQuery solution. For example, I could imagine there must be a way using jQuery to wrap each field/value pair in a div:
<div>
<div class="display-label">Label 1</div>
<div class="display-field">Value 1</div>
</div>
<div>
<div class="display-label">Label 1</div>
<div class="display-field">Value 1</div>
</div>
...
which can then be styled as a table:
#table
{
display:table;
}
#table > div
{
display: table-row;
}
#table .display-label
,#table .display-field
{
display:table-cell;
}