CSS + Div implement table layout
CSSCode
< Style >
. Table /**/ /*Div table container*/
{
/**//*Width: 770px;*/
}
. Row Div /**/ /*Div row cell*/
{
Display: inline;
Width: 240px;
Border-Top: 1px solid # c1bbab;
Border-Left: 1px solid # c1bbab;
}
. Header Div /**/ /*Div header Cell*/
{
Display: inline;
Width: 240px;
Border-Top: 1px solid # c1bbab;
Border-Left: 1px solid # c1bbab;
Text-Align: center;
Background-Color: # e0ddd5;
}
. Lastcell /**/ /*Last cell*/
{
Border-Right: 1px solid # c1bbab;
}
. Header /**/ /*Div table hearder*/
{
Font: bold;
Color: Navy;
}
. Grid_rw1clr Div /**/ /*Cell in grid_rw1clr*/
{
Background-Color: # ffffff;
}
. Grid_rw2clr Div /**/ /*Cell in grid_rw1clr*/
{
Background-Color: # f9f8f6;
}
. Row
{
Font: normal 12px;
}
. Lastrow Div /**/ /*Cell in last row*/
{
Border-Bottom: 1px solid # c1bbab;
}
</ Style >
Set border-left and border-top for each cell. Such cells are combined into rows, and only the bottom border of the last and last row is missing. Special processing is required, therefore, two other classes are defined: lastcell and lastrow. The final table border will not overlap.
Class: grid_rw1clr and grid_rw2clr achieve alternating colors
CSS table Effect
Header (1, 1) header (1, 2) Row (1, 1) Row (1, 2) Row (2, 2)
HTML code < Div Class = " Table " >
< Div Class = " Header " > < Div > Header ( 1 , 1 ) </ Div > < Div Class = " Lastcell " > Header ( 1 , 2 ) </ Div > </ Div >
< Div Class = " Row grid_rw1clr " > < Div > Row ( 1 , 1 ) </ Div > < Div Class = " Lastcell " > Row ( 1 , 2 ) </ Div > </ Div >
< Div Class = " Row grid_rw2clr lastrow " > < Div > Row ( 2 , 1 ) </ Div > < Div Class = " Lastcell " > Row ( 2 , 2 ) </ Div > </ Div >
</ Div >
Next we need to implement: