1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Test: table-layout fixed - columns with percentage width and absolute width</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
<link rel="help" href="http://www.w3.org/TR/CSS21/tables.html#fixed-table-layout" title="17.5.2.1 Fixed table layout" />
<link rel="match" href="fixed-table-layout-023-ref.xht" />
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<meta content="A column with a percentage width in a 'table-layout: fixed' table can be calculated, predicted, rendered." name="assert" />
<style type="text/css"><![CDATA[
body
{
margin: 8px;
width: 640px;
}
table, div {font: 1.25em/1 Ahem;}
table
{
border: white solid;
border-width: 0px 11px; /* horizontal table border width is 22px total */
border-collapse: separate;
border-spacing: 18px 4px; /* horizontal border-spacing width is 90px total */
table-layout: fixed;
width: 80%; /* 640px mult by 80% == 512px */
/*
"With this (fast) algorithm, the horizontal layout of
the table does not depend on the contents of the cells;
it only depends on the table's width, the width of
the columns, and [table] borders or cell spacing."
So,
512px : total table width
-
90px : total horizontal border-spacing width
-
22px : total horizontal border-spacing width
========
400px : total to split among the 4 columns
*/
}
col#first
{
background-color: fuchsia;
width: 13%;
/* 400px multiplied by 13% = 52px */
}
col#second
{
background-color: olive;
width: 100px;
}
col#third
{
background-color: orange;
width: 31%;
/* 400px multiplied by 31% = 124px */
/*
400px - (52px + 100px + 124px) = 124px for last column
*/
}
col#fourth {background-color: lime;}
td {padding: 1px 10px;}
td#first-cell {color: fuchsia;}
td#second-cell {color: olive;}
td#third-cell {color: orange;}
td#fourth-cell {color: lime;}
div {padding: 1px 0px;}
div#reference1st
{
background-color: fuchsia;
color: fuchsia;
left: 29px; /* 11px border-left of table + 18px border-spacing == 29px */
position: relative;
width: 52px;
}
div#reference2nd
{
background-color: olive;
bottom: 1.1em;
color: olive;
left: 99px;
/*
11px : border-left of table
+
18px : 1st border-spacing
+
52px : width of first column
+
18px : 2nd border-spacing
=======
99px
*/
position: relative;
width: 100px;
}
div#reference3rd
{
background-color: orange;
bottom: 2.2em;
color: orange;
left: 217px;
/*
11px : border-left of table
+
18px : 1st border-spacing
+
52px : width of first column
+
18px : 2nd border-spacing
+
100px : width of second column
+
18px : 3rd border-spacing
=======
217px
*/
position: relative;
width: 124px;
}
div#reference4th
{
background-color: lime;
bottom: 3.3em;
color: lime;
left: 359px;
/*
11px : border-left of table
+
18px : 1st border-spacing
+
52px : width of first column
+
18px : 2nd border-spacing
+
100px : width of second column
+
18px : 3rd border-spacing
+
124px : width of third column
+
18px : 4th border-spacing
=======
359px
*/
position: relative;
width: 124px;
}
]]></style>
</head>
<body>
<p>Test passes if the colored (fuchsia, olive, orange and lime) stripes have respectively the same widths and the same horizontal positions.</p>
<table>
<col id="first"></col>
<col id="second"></col>
<col id="third"></col>
<col id="fourth"></col>
<tr>
<td id="first-cell">1</td>
<td id="second-cell">2</td>
<td id="third-cell">3</td>
<td id="fourth-cell">4</td>
</tr>
</table>
<div id="reference1st">r</div>
<div id="reference2nd">r</div>
<div id="reference3rd">r</div>
<div id="reference4th">r</div>
</body>
</html>
|