Nested DIV table displays incorrectly - html

I have problems coding a nested DIV table:
.divTable {
display: table;
width: 100%;
}
.divTableRow {
display: table-row;
}
.divTableHeading {
background-color: #EEE;
display: table-header-group;
}
.divTableCell,
.divTableHead {
display: table-cell;
padding: 3px 10px;
}
.divTableHeading {
background-color: #EEE;
display: table-header-group;
font-weight: bold;
}
.divTableFoot {
background-color: #EEE;
display: table-footer-group;
font-weight: bold;
}
.divTableBody {
display: table-row-group;
}
.divTable2 {
display: table;
width: 100%;
}
.divTable2Row {
display: table-row;
}
.divTable2Cell,
.divTable2Body {
display: table-row-group;
}
<div class="divTable">
<div class="divTableBody">
<div class="divTableRow">
<!-- this row contains a nested 2x2 table -->
<div class="divTableCell">outer left </div>
<div class="divTableCell">outer right
<div class="divTable2">
<div class="divTable2Body">
<div class="divTable2Row">
<div class="divTable2Cell">inner 1st line left</div>
<div class="divTable2Cell">inner 1st line right</div>
</div>
<div class="divTable2Row">
<div class="divTable2Cell">inner 2nd line left</div>
<div class="divTable2Cell">inner 2nd line right</div>
</div>
</div>
</div>
</div>
</div>
<div class="divTableRow">
<!-- no nested table here -->
<div class="divTableCell">outer left</div>
<div class="divTableCell">outer right</div>
</div>
</div>
<!-- end div divTable Body -->
</div>
<!-- end div divTable -->
https://jsfiddle.net/jsrookey/0z0agxad/
The nested table cells are not on the same table row line, but underneath each other, strangely.

That's because .divTable2Cell has display: table-row-group; instead of display: table-cell;.
.divTable {
display: table;
width: 100%;
}
.divTableRow {
display: table-row;
}
.divTableHeading {
background-color: #EEE;
display: table-header-group;
}
.divTableCell,
.divTable2Cell,
.divTableHead {
display: table-cell;
padding: 3px 10px;
}
.divTableHeading {
background-color: #EEE;
display: table-header-group;
font-weight: bold;
}
.divTableFoot {
background-color: #EEE;
display: table-footer-group;
font-weight: bold;
}
.divTableBody {
display: table-row-group;
}
.divTable2 {
display: table;
width: 100%;
}
.divTable2Row {
display: table-row;
}
.divTable2Body {
display: table-row-group;
}
<div class="divTable">
<div class="divTableBody">
<div class="divTableRow">
<!-- this row contains a nested 2x2 table -->
<div class="divTableCell">outer left </div>
<div class="divTableCell">outer right
<div class="divTable2">
<div class="divTable2Body">
<div class="divTable2Row">
<div class="divTable2Cell">inner 1st line left</div>
<div class="divTable2Cell">inner 1st line right</div>
</div>
<div class="divTable2Row">
<div class="divTable2Cell">inner 2nd line left</div>
<div class="divTable2Cell">inner 2nd line right</div>
</div>
</div>
</div>
</div>
</div>
<div class="divTableRow">
<!-- no nested table here -->
<div class="divTableCell">outer left</div>
<div class="divTableCell">outer right</div>
</div>
</div>
<!-- end div divTable Body -->
</div>
<!-- end div divTable -->
FWIW you have some unnecessary duplication in CSS classes, i.e. the following are the same:
.divTable, .divTable2
.divTableBody, .divTable2Body
.divTableRow, .divTable2Row
.divTableCell, .divTable2Cell
etc.
Merge them into a single class.
.table {
display: table;
width: 100%;
}
.tbody {
display: table-row-group;
}
.thead {
background-color: #EEE;
display: table-header-group;
font-weight: bold;
}
.tfoot {
background-color: #EEE;
display: table-footer-group;
font-weight: bold;
}
.tr {
display: table-row;
}
.td,
.th {
display: table-cell;
padding: 3px 10px;
}
<div class="table">
<div class="tbody">
<div class="tr">
<div class="td">outer left </div>
<div class="td">outer right
<div class="table">
<div class="tbody">
<div class="tr">
<div class="td">inner 1st line left</div>
<div class="td">inner 1st line right</div>
</div>
<div class="tr">
<div class="td">inner 2nd line left</div>
<div class="td">inner 2nd line right</div>
</div>
</div>
</div><!-- .table -->
</div>
</div>
<div class="tr">
<div class="td">outer left</div>
<div class="td">outer right</div>
</div>
</div>
</div>

Related

Vertical line between table rows. Merge two cells (headers)

I added a few simple tables in HTML. I am looking for a solution for two issues.
1)
After I added this tables on my subpage I see that the tables are almost the same but they have in different place their horizontal line between table rows.
2)
I would like to merge two headers.
I can't fix this using code-Live editor.
div.blueTable {
border: 0px solid #FFFFFF;
background-color: #EEEEEE;
width: 100%;
text-align: left;
border-collapse: collapse;
}
.divTable.blueTable .divTableCell,
.divTable.blueTable .divTableHead {
border: 1px solid #AAAAAA;
padding: 3px 5px;
text-align: left;
}
.divTable.blueTable .divTableBody .divTableCell {
font-size: 13px;
}
.divTable.blueTable .divTableRow:nth-child(even) {
background: #FFFFFF;
}
.divTable.blueTable .divTableHeading {
background: #5DBCD2;
border-bottom: 2px solid #444444;
}
.divTable.blueTable .divTableHeading .divTableHead {
font-size: 14px;
font-weight: bold;
color: #FFFFFF;
text-align: left;
border-left: 0px solid #F5F4F4;
}
.divTable.blueTable .divTableHeading .divTableHead:first-child {
border-left: none;
}
.blueTable .tableFootStyle {
font-size: 14px;
}
.blueTable .tableFootStyle .links {
text-align: right;
}
.blueTable .tableFootStyle .links a {
display: inline-block;
background: #1C6EA4;
color: #FFFFFF;
padding: 2px 8px;
border-radius: 5px;
}
.blueTable.outerTableFooter {
border-top: none;
}
.blueTable.outerTableFooter .tableFootStyle {
padding: 3px 5px;
}
.divTable {
display: table;
}
.divTableRow {
display: table-row;
}
.divTableHeading {
display: table-header-group;
}
.divTableCell,
.divTableHead {
display: table-cell;
}
.divTableHeading {
display: table-header-group;
}
.divTableFoot {
display: table-footer-group;
}
.divTableBody {
display: table-row-group;
}
<div class="divTable blueTable" style="width: 100%">
<div class="divTableHeading">
<div class="divTableRow">
<div class="divTableHead">People</div>
<div class="divTableHead"></div>
</div>
</div>
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell">Lang</div>
<div class="divTableCell">54</div>
</div>
<div class="divTableRow">
<div class="divTableCell">Height</div>
<div class="divTableCell">22</div>
</div>
<div class="divTableRow">
<div class="divTableCell">Weight</div>
<div class="divTableCell">66</div>
</div>
<div class="divTableRow">
<div class="divTableCell">Et</div>
<div class="divTableCell">55</div>
</div>
<div class="divTableRow">
<div class="divTableCell">Color</div>
<div class="divTableCell">wb</div>
</div>
<div class="divTableRow">
<div class="divTableCell">A</div>
<div class="divTableCell">10</div>
</div>
</div>
</div>
</br>
</br>
<div class="divTable blueTable" style="width: 100%">
<div class="divTableHeading">
<div class="divTableRow">
<div class="divTableHead">Country</div>
<div class="divTableHead"></div>
</div>
</div>
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell">E</div>
<div class="divTableCell">11</div>
</div>
<div class="divTableRow">
<div class="divTableCell">P</div>
<div class="divTableCell">23</div>
</div>
<div class="divTableRow">
<div class="divTableCell">R</div>
<div class="divTableCell">32</div>
</div>
<div class="divTableRow">
<div class="divTableCell">H</div>
<div class="divTableCell">45</div>
</div>
<div class="divTableRow">
<div class="divTableCell">I</div>
<div class="divTableCell">57</div>
</div>
</div>
</div>
</br>
</br>
In answer to your first issue... I've had a good play around and if it is the vertical divider between the cells, then I believe it's a table resizing issue when characters are removed or added.
To prevent this, simply add table-layout: fixed; to the outermost container of the table, in your case it would be .divTable. With thanks to this SO answer.
.divTable {
table-layout: fixed;
}
See this JSFiddle for the fix.
Check out this Mozilla docs to read up about the table-layout property.
In regards to your second issue, please explain in detail what you mean and wanting to achieve by editing/updating your question.
Lastly, I would highly recommend you read up on the Bootstrap docs, and implement it into your project if haven't already. It helps you to achieve the goals with ease. Bootstrap also has a table structure too, which would be useful in your case.

html "display: table" If we do not set the height, we know that it appears the same. But it seems different from what I know

My structure is
<div height : 240px>
<div display : table>
<div display : table-row>
<div display : table-cell>
<div display : table-row>
<div display : table-cell>
<div display : table-row>
<div display : table-cell>
I know that 80px should come out.
but table-row height is not 80px..
why ,,?
You have set the height for the div which has the display: table.
/* DivTable.com */
.divTable{
display: table;
width: 100%;
height: 240px;
}
.divTableRow {
display: table-row;
}
.divTableHeading {
display: table-header-group;
}
.divTableCell, .divTableHead {
display: table-cell;
border: 1px solid;
}
.divTableHeading {
display: table-header-group;
}
.divTableFoot {
display: table-footer-group;
}
.divTableBody {
display: table-row-group;
}
<div class="divTable">
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell"></div>
<div class="divTableCell"></div>
<div class="divTableCell"></div>
</div>
<div class="divTableRow">
<div class="divTableCell"></div>
<div class="divTableCell"></div>
<div class="divTableCell"></div>
</div>
<div class="divTableRow">
<div class="divTableCell"></div>
<div class="divTableCell"></div>
<div class="divTableCell"></div>
</div>
</div>
</div>

CSS element keeps going to new line

I want to keep the text block always on the first line, and if it needs multiple lines, then those lines should always get created beneath the first line of text.
The objective is that you only see dates on the left part of the page.
what is happening:
enter image description here
what should be happening:
enter image description here
/* Magic */
* {
margin: 0;
padding: 0;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
ul {
margin-left:20px;
}
/* MAIN STRUCTURE */
.page {
margin: 20px 20px 20px 20px;
font-size: 1.1rem;
}
#header {
width: 100%;
z-index: 1;
display: inline-block;
}
.section {
margin-top: 15px;
display: inline-block;
width: 100%;
}
/* Header */
#title {
float: left;
font-size: 1.3rem;
}
#meta {
float: right;
}
/* section */
.timeline_entry {
display: inline-block;
width: 100%;
margin-bottom: 1rem;
}
.entry {
display: inline-block;
width: 100%;
}
#identity {
}
#current {
}
#actions {
}
#stats {
}
#listing {
}
/* entry */
.element {
display: inline-block;
margin-right: 0.8rem;
}
.word {
display: inline-block;
}
#editing{
display: inline-block;
text-align: left;
float: right;
}
#proposal_status {
}
#proposal_text {
}
/* header */
#user_actions{
}
<div class="section" id="listing">
<div class="timeline_entry">
<div class="entry">
<div class="element">
<div class="word">2015-09-23</div>
<div class="word">#</div>
</div>
<div class="element">This is a long text which is going to the second line because its so big you know? more text, moarr</div>
</div>
<div class="entry">
<div class="element">
<div class="word">2015-09-23</div>
<div class="word">#</div>
</div>
<div class="element">Achieved</div>
<div class="element">Talk (5)</div>
<div class="element">
<div class="word">Category</div>
<div class="word">Category</div>
</div>
</div>
</div>
<div class="timeline_entry">
<div class="entry">
<div class="element">
<div class="word">2015-09-23</div>
<div class="word">#</div>
</div>
<div class="element">This text stays where it should</div>
</div>
<div class="entry">
<div class="element">
<div class="word">2015-09-23</div>
<div class="word">#</div>
</div>
<div class="element">Achieved</div>
<div class="element">Talk (5)</div>
<div class="element">
<div class="word">Category</div>
<div class="word">Category</div>
</div>
</div>
</div>
</div>
you could try playing around with HTMLs much underloved "Deffinition List" <dl>
Alternatively, here's a table-like layout:
.list-group {
display:table;
width:100%;
max-width:500px;
}
.item {
display:table-row;
}
.date {
display:table-cell;
width:30%;
padding:10px;
vertical-align:top;
text-align:right;
}
.dates {
display:table-cell;
width:70%;
padding:10px;
vertical-align:top;
}
<div class="list-group">
<div class="item">
<div class="date">2015 09 14</div>
<div class="dates">2013123 2013123 2013123 2013123 2013123 2013123 2013123</div>
</div>
<div class="item">
<div class="date">2015 09 14</div>
<div class="dates">2013123 2013123 2013123 2013123 2013123 2013123 2013123</div>
</div>
<div class="item">
<div class="date">2015 09 14</div>
<div class="dates">2013123 2013123 2013123 2013123 2013123 2013123 2013123</div>
</div>
<div class="item">
<div class="date">2015 09 14</div>
<div class="dates">2013123 2013123 2013123 2013123 2013123 2013123 2013123</div>
</div>
</div>
I was hoping to comment but I don't have enough rep points to do so, but would the below work?
JSFiddle: https://jsfiddle.net/4r295p0q/2/
This won't work if your class assignments aren't flexible because I changed the classes of the two DIV's with the text from .element (red border) to .post (blue border). From there, I gave the new .post class an pre-determined width percentage and float: right.

CSS DIV as table - how to make all column same height as the highest

I have some problems with my DIV table.. maybe there is a better way to do this.
I want to have all columns to be the same height as the highest column. Is there a way to do it? or is there another way to make this work ?
I have to made a jsfiddle example here with my code: http://jsfiddle.net/rb500o4L/ (right column is higher than left, middle and the logo column.)
My CSS code:
div.round-border {
border: solid 1px;
border-color: #002F67;
border-radius: 10px;
}
#container {
display: table;
width: 100%;
}
#row {
display: table-row;
}
#cell {
display: table-cell;
}
#cell-logo {
display: table-cell;
width: 200px;
}
My HTML code:
<div id="container">
<div id="row">
<div id="cell">
<div class="round-border">
<h4>Left Col</h4>
<p>...</p>
</div>
</div>
<div id="cell">
<div class="round-border">
<h4>Middle Col</h4>
<p>...</p>
</div>
</div>
<div id="cell">
<div class="round-border">
<h4>Right Col</h4>
<p>...</p>
<p>...</p>
</div>
</div>
<div id="cell-logo">
<div class="round-border">
<h4>LOGO AREA</h4>
<p>...</p>
</div>
</div>
</div>
</div>
I appreciate any recommendation.
use this css
div.round-border {
border: solid 1px;
border-color: #002F67;
border-radius: 10px;
}
container {
width: 100%;
}
row {
height:auto;
}
#cell
{
height:auto;
min-height:400px;
width:50px;
display:inline-block;
}
#cell-logo {
width: 50px;
}

Colspan/Rowspan for elements whose display is set to table-cell

I have the following code:
.table {
display: table;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
}
.colspan2 {
/* What to do here? */
}
<div class="table">
<div class="row">
<div class="cell">Cell</div>
<div class="cell">Cell</div>
</div>
<div class="row">
<div class="cell colspan2">Cell</div>
</div>
</div>
Pretty straightforward. How do I add a colspan (or the equivalent of colspan) for elements with display: table-cell?
As far as I know, the lack of colspan/rowspan is just one of the limitations of display:table. See this post:
http://www.onenaught.com/posts/201/use-css-displaytable-for-layout
Since OP does not explicitly rule that solution must be pure CSS, I'll be stubborn and throw in my workaround I figured out today, especially since it's much more elegant than having a table inside a table.
Example equals to <table> with two cells per row and two rows, where the cell in the second row is a td with colspan="2".
I have tested this with Iceweasel 20, Firefox 23 and IE 10.
div.table {
display: table;
width: 100px;
background-color: lightblue;
border-collapse: collapse;
border: 1px solid red;
}
div.row {
display: table-row;
}
div.cell {
display: table-cell;
border: 1px solid red;
}
div.colspan,
div.colspan+div.cell {
border: 0;
}
div.colspan>div {
width: 1px;
}
div.colspan>div>div {
position: relative;
width: 99px;
overflow: hidden;
}
<div class="table">
<div class="row">
<div class="cell">cell 1</div>
<div class="cell">cell 2</div>
</div>
<div class="row">
<div class="cell colspan">
<div><div>
cell 3
</div></div>
</div>
<div class="cell"></div>
</div>
</div>
Live action (demo) here.
EDIT:
I finetuned the code to be more printer-friendly, as they leave background-colors out by default. I also created rowspan-demo, inspired by late answer here.
A simpler solution that works for me in Chrome 30 :
Colspan can be emulated by using display: table instead of display: table-row for the rows :
.table {
display: block;
}
.row {
display: table;
width: 100%;
}
.cell {
display: table-cell;
}
.row.colspan2 {/* You'll have to add the 'colspan2' class to the row, and remove the unused <div class=cell> inside it */
display: block;
}
The only pitfall is that the cells of stacked rows won't align vertically, as they're from different tables.
If you're looking for a straight CSS way to simulate a colspan, you could use display: table-caption.
.table {
display: table;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
border: 1px solid #000;
}
.colspan2 {
/* What to do here? */
display: table-caption;
}
<div class="table">
<div class="row">
<div class="cell">Cell</div>
<div class="cell">Cell</div>
</div>
<div class="row">
<div class="cell colspan2">Cell</div>
</div>
</div>
Simply use a table.
table's are only frowned upon when being used for layout purposes.
This seems like tabular data (rows/columns of data). Therefore I would recommend using a table.
See my answer to this question for more information:
creating the same thing with divs as tables
Here's one way to span columns in CSS I used for my own situation.
https://jsfiddle.net/mb8npttu/
.table {
display: table;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
border: 1px dotted red;
}
.colspan {
max-width: 1px;
overflow: visible;
}
<div class='table'>
<div class='row'>
<div class='cell colspan'>
spanning
</div>
<div class='cell'></div>
<div class='cell'></div>
</div>
<div class='row'>
<div class='cell'>1</div>
<div class='cell'>2</div>
<div class='cell'>3</div>
</div>
</div>
There is a solution to make the colspan the widht of the entire table. You can not use this technique to colspan a part of the table.
Code:
* {
box-sizing: border-box;
}
.table {
display: table;
position: relative;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
border: 1px solid red;
padding: 5px;
text-align: center;
}
.colspan {
position: absolute;
left: 0;
width: 100%;
}
.dummycell {
border-color: transparent;
}
<div class="table">
<div class="row">
<div class="cell">Cell</div>
<div class="cell">Cell</div>
</div>
<div class="row">
<div class="cell dummycell"> </div>
<div class="cell colspan">Cell</div>
</div>
<div class="row">
<div class="cell">Cell</div>
<div class="cell">Cell</div>
</div>
</div>
Explanation:
We use position absolute on the colspan to make it the full width of the table. The table itself needs position relative. We make use of a dummycell to maintain the height of the rows, position absolute does not follow the flow of the document.
Of course you can also use flexbox and grid to tackle this problem these days.
CSS
.tablewrapper {
position: relative;
}
.table {
display: table;
position: relative
}
.row {
display: table-row;
}
.cell {
border: 1px solid red;
display: table-cell;
}
.cell.empty
{
border: none;
width: 100px;
}
.cell.rowspanned {
position: absolute;
top: 0;
bottom: 0;
width: 100px;
}
.cell.colspan {
position: absolute;
left: 0;
right: 0;
}
HTML
<div class="tablewrapper">
<div class="table">
<div class="row">
<div class="cell rowspanned">
Center
</div>
<div class="cell">
Top right
</div>
</div>
<div class="row">
<div class="cell empty"></div>
<div class="cell colspan">
Bottom right
</div>
</div>
</div>
</div>
Code
It can be done just with pure CSS and centering the text across the "fake" colspan.
The trick is to set the rows to position:relative, then to place "empty divs" in the row where you want to make the colspan (they must have height in order to work), set the cell where the content is in as display:grid, and finally, applying position:absolute to the element inside the cell (and center it as you may center any other absolute element).
.table {
display: table;
}
.row {
display: table-row;
position: relative;
}
.cell {
display: table-cell;
background-color: blue;
color: white;
height: 26px;
padding: 0 8px;
}
.colspan2 {
display: grid;
}
.colspan2 p {
position:absolute;
left: 50%;
transform:translateX(-50%);
margin: 0;
}
<div class="table">
<div class="row">
<div class="cell">Cell</div>
<div class="cell">Cell</div>
</div>
<div class="row">
<div class="cell colspan2"><p>Cell</p></div>
<div class="cell"></div>
</div>
</div>
By using the appropriate div classes and CSS attributes, you can mimic the desired effects of the colspan and rowspan.
Here's the CSS
.table {
display:table;
}
.row {
display:table-row;
}
.cell {
display:table-cell;
padding: 5px;
vertical-align: middle;
}
Here's the sample HTML
<div class="table">
<div class="row">
<div class="cell">
<div class="table">
<div class="row">
<div class="cell">X</div>
<div class="cell">Y</div>
<div class="cell">Z</div>
</div>
<div class="row">
<div class="cell">2</div>
<div class="cell">4</div>
<div class="cell">6</div>
</div>
</div>
</div>
<div class="cell">
<div class="table">
<div class="row">
<div class="cell">
<div class="table">
<div class="row">
<div class="cell">A</div>
</div>
<div class="row">
<div class="cell">B</div>
</div>
</div>
</div>
<div class="cell">
ROW SPAN
</div>
</div>
</div>
</div>
</div>
</div>
From what I'm seeing in both the questions, and most responses, is people seem to forget that in any given div that's acting as a "table-cell" you can insert another div that's acting like an embedded table, and start the process over.
***It's not glamorous, but it does work for those looking for this type of formatting and they want to avoid the TABLEs. If its for DATA LAYOUT, TABLEs do still work in HTML5.
Hopefully, this will help someone.
You can set the position of colspan content as "relative" and the row as "absolute" like this:
.table {
display: table;
}
.row {
display: table-row;
position: relative;
}
.cell {
display: table-cell;
}
.colspan2 {
position: absolute;
width: 100%;
}
You can't achieve this at present.
AFAIK this would be covered by CSS Tables, a specification which appears to currently be at "work in progress" state.
You can try this solution, where you can find how to apply colspan using div
https://codepen.io/pkachhia/pen/JyWMxY
HTML:
<div class="div_format">
<div class="divTable">
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell cell_lable">Project Name</div>
<div class="divTableCell cell_value">: Testing Project</div>
<div class="divTableCell cell_lable">Project Type</div>
<div class="divTableCell cell_value">: Web application</div>
</div>
<div class="divTableRow">
<div class="divTableCell cell_lable">Version</div>
<div class="divTableCell cell_value">: 1.0.0</div>
<div class="divTableCell cell_lable">Start Time</div>
<div class="divTableCell cell_value">: 2016-07-10 11:00:21</div>
</div>
<div class="divTableRow">
<div class="divTableCell cell_lable">Document Version</div>
<div class="divTableCell cell_value">: 2.0.0</div>
<div class="divTableCell cell_lable">End Time</div>
<div class="divTableCell cell_value">: 2017-07-10 11:00:23</div>
</div>
<div class="divTableRow">
<div class="divTableCell cell_lable">Document Revision</div>
<div class="divTableCell cell_value">: 3</div>
<div class="divTableCell cell_lable">Overall Result</div>
<div class="divTableCell cell_value txt_bold txt_success">: Passed</div>
</div>
</div>
<div class="divCaptionRow">
<div class="divCaptionlabel">Description</div>
<div class="divCaptionValue">: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore</div>
</div>
</div>
</div>
CSS:
body {
font-family: arial
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box
}
.div_format {
width: 100%;
display: inline-block;
position: relative
}
.divTable {
display: table;
width: 100%;
}
.divTableRow {
display: table-row
}
.divTableHeading {
background-color: #EEE;
display: table-header-group
}
.divTableCell,
.divTableHead {
display: table-cell;
padding: 10px
}
.divTableHeading {
background-color: #EEE;
display: table-header-group;
font-weight: bold
}
.divTableFoot {
background-color: #EEE;
display: table-footer-group;
font-weight: bold
}
.divTableBody {
display: table-row-group
}
.divCaptionRow{
display: table-caption;
caption-side: bottom;
width: 100%;
}
.divCaptionlabel{
caption-side: bottom;
display: inline-block;
background: #ccc;
padding: 10px;
width: 15.6%;
margin-left: 10px;
color: #727272;
}
.divCaptionValue{
float: right;
width: 83%;
padding: 10px 1px;
border-bottom: 1px solid #dddddd;
border-right: 10px solid #fff;
color: #5f5f5f;
text-align: left;
}
.cell_lable {
background: #d0d0d0;
border-bottom: 1px solid #ffffff;
border-left: 10px solid #ffffff;
border-right: 10px solid #fff;
width: 15%;
color: #727272;
}
.cell_value {
border-bottom: 1px solid #dddddd;
width: 30%;
border-right: 10px solid #fff;
color: #5f5f5f;
}
Use nested tables to nest column spans...
<div class="table">
<div class="row">
<div class="cell">
<div class="table">
<div class="row">
<div class="cell">Cell</div>
<div class="cell">Cell</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="cell">Cell</div>
</div>
</div>
Or use 2 tables where the column span covers the whole row...
<div class="table">
<div class="row">
<div class="cell">Cell</div>
<div class="cell">Cell</div>
</div>
</div>
<div class="table">
<div class="row">
<div class="cell">Cell</div>
</div>
</div>
Even if this is an old question, I would like to share my solution to this problem.
<div class="table">
<div class="row">
<div class="cell">Cell</div>
<div class="cell">Cell</div>
</div>
<div class="row">
<div class="cell colspan">
<div class="spanned-content">Cell</div>
</div>
</div>
</div>
<style>
.table {
display: table;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
}
.colspan:after {
/* What to do here? */
content: "c";
display: inline;
visibility: hidden;
}
.spanned-content {
position: absolute;
}
</style>
Here is a fiddle.
It's not really a span, and the solution is a bit hacky, but it is usefull in some situations. Tested on Chrome 46, Firefox 31 and IE 11.
In my case, I had to present some non-tabular data in a tabular way, keeping the width of the columns and giving title to sub-sections of the data.