I'm trying to construct a layout similar to the following:
+---+---+---+
| | | |
+---+---+---+
| |
+-----------+
where the bottom is filling the space of the upper row.
If this were an actual table, I could easily accomplish this with <td colspan="3">
, but as I'm simply creating a table-like layout, I cannot use <table>
tags. Is this possible using CSS?
You could trying using a grid system like http://960.gs/
Your code would be something like this, assuming you're using a "12 column" layout:
http://www.quackit.com/css/css3/properties/css_column-span.cfm
Another suggestion is using flexbox instead of tables altogether. This is a "modern browser" thing of course, but come on, it's 2016 ;)
At least this might be an alternative solution for those looking for an answer to this nowadays, since the original post was from 2010.
Here's a great guide: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
There is no colspan in css as far as I know, but there will be
column-span
for multi column layout in the near future, but since it is only a draft in CSS3, you can check it in here. Anyway you can do a workaround usingdiv
andspan
with table-like display like this.This would be the HTML:
And this would be the css:
The only reason to use this trick is to gain the benefit of
table-layout
behaviour, I use it alot if only setting div and span width to certain percentage didn't fullfil our design requirement.But if you don't need to benefit from the
table-layout
behaviour, then durilai's answer would suit you enough.if you use div and span it will occupy more code size when the datagrid-table row are more in volume. This below code is checked in all browsers
HTML:
CSS:
If you come here because you have to turn on or off the
colspan
attribute (say for a mobile layout):Duplicate the
<td>
s and only show the ones with the desiredcolspan
: