I\'m creating a html template that wraps a table that is used to lay out a form. I have full control over the html that wraps the table not the table itself. The table is in
Simply; No. You cannot turn a row turn a 2-column table into a 1-column table without some JavaScript.
Either tell the coders of the table to create the table that way, or simply use JavaScript to re-structure the table.
Actually, it's incredibly easy (and can be done with 2 lines of css): Make your td width 100% and set overflow:auto. Your second column will automatically wrap around.
Nope, this is not reasonably possible without changing the markup. Tables in HTML are structured as rows, not as columns. In the example you give you're re-ordering the content:
Original order:
Column 1 -> Column 2 -> this-is-col-1 -> this-is-col-2
New ordering:
Column 1 -> this-is-col-1 -> Column 2 -> this-is-col-2
Why did I say "not reasonably possible"? Well, with absolute positioning and similar techniques you may be able to hack the layout you want together - but there's a world of CSS-hurt waiting as I don't expect that approach to play nice in a real page.
Additional note: To add to the "re-ordering" problem, something that may be a little easier to accomplish would be this layout, where the order stays the same:
----------------------------
|Column 1 |
-----------------------------
|Column 2 |
-----------------------------
|this is column 1 |
-----------------------------
| this is column 2 |
-----------------------------
But that's obviously not what you want.
You can achieve something similar by using display:block;
.
See this fiddle: http://jsfiddle.net/R53KH/
Try adding this to you CSS:
td {
display: table-row;
}
Cheers.
Still having issues and in Chrome?
For those still having issues (like me) check you have <!DOCTYPE html>
in the head of your document. If you don't Chrome seems to totally ignore anything you add and keep display: table-cell
.