fixed-table-layout-018.xht (2498B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 5 <head> 6 7 <title>CSS Test: table-layout fixed - columns with percentage width</title> 8 9 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> 10 <link rel="help" href="http://www.w3.org/TR/CSS21/tables.html#fixed-table-layout" title="17.5.2.1 Fixed table layout" /> 11 <link rel="match" href="fixed-table-layout-017-ref.xht" /> 12 <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> 13 14 <meta content="A column with a percentage width in a 'table-layout: fixed' table can be calculated and predicted when in 'border-collapse: separate' model." name="assert" /> 15 16 <style type="text/css"><![CDATA[ 17 table, div {font: 1.25em/1 Ahem;} 18 19 table 20 { 21 border: solid white; 22 border-width: 0px 6px; 23 border-collapse: separate; 24 border-spacing: 2px 4px; 25 table-layout: fixed; 26 width: 422px; 27 } 28 29 col#test 30 { 31 background-color: orange; 32 width: 40%; 33 } 34 35 td#third-cell {color: orange;} 36 37 div, td {padding: 1px 0px;} 38 39 div#reference 40 { 41 background-color: blue; 42 color: blue; 43 left: 172px; 44 /* 45 3 horizontal border-spacing and the table 46 border-left separate the start 47 of table box and the start of 3rd column. 48 The first 2 columns should each be 80px exactly 49 since "Any remaining columns equally divide the 50 remaining horizontal table space (minus [table] borders or 51 cell spacing)." So: 52 53 6px : table border-left 54 + 55 2px : 1st border-spacing 56 + 57 80px : 1st column : (422 - 10 - 12) mult by (60% divided by 3) 58 + 59 2px : 2nd border-spacing 60 + 61 80px : 2nd column : (422 - 10 - 12) mult by (60% divided by 3) 62 + 63 2px : 3rd border-spacing 64 ========= 65 172px 66 */ 67 68 position: relative; 69 width: 160px; 70 71 /* 72 73 422px : total width of table 74 - 75 12px : total width of horizontal borders of table 76 - 77 10px : 5 times horizontal border-spacing 78 ======== 79 400px 80 mult by 81 40% 82 ======== 83 160px 84 85 */ 86 } 87 ]]></style> 88 89 </head> 90 91 <body> 92 93 <p>Test passes if the orange stripe is exactly as wide as the blue stripe and is horizontally positioned the same.</p> 94 95 <table> 96 97 <col></col> 98 <col></col> 99 <col id="test"></col> 100 <col></col> 101 102 <tr> 103 <td></td> 104 <td></td> 105 <td id="third-cell">col</td> 106 <td></td> 107 </tr> 108 109 </table> 110 111 <div id="reference">ref</div> 112 113 </body> 114 </html>