fixed-table-layout-017.xht (2397B)
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-collapse: separate; 22 border-spacing: 4px; 23 table-layout: fixed; 24 width: 420px; 25 } 26 27 col#test 28 { 29 background-color: orange; 30 width: 40%; 31 } 32 33 td#third-cell {color: orange;} 34 35 div, td {padding: 1px 0px;} 36 37 div#reference 38 { 39 background-color: blue; 40 color: blue; 41 left: 172px; 42 /* 43 3 horizontal border-spacing separate the start 44 of table box and the start of 3rd column. 45 The first 2 columns should each be 80px exactly 46 since "Any remaining columns equally divide the 47 remaining horizontal table space (minus [table] borders or 48 cell spacing)." So: 49 50 0px : table border-left 51 + 52 4px : 1st border-spacing 53 + 54 80px : 1st column : (420 - 20) mult by (60% divided by 3) 55 + 56 4px : 2nd border-spacing 57 + 58 80px : 2nd column : (420 - 20) mult by (60% divided by 3) 59 + 60 4px: 3rd border-spacing 61 ======== 62 172px 63 */ 64 65 position: relative; 66 width: 160px; 67 68 /* 69 70 420px : total width of table 71 - 72 20px : 5 times horizontal border-spacing 73 - 74 0px : total of horizontal table borders 75 ======== 76 400px 77 mult by 78 40% 79 ======== 80 160px 81 82 */ 83 } 84 ]]></style> 85 86 </head> 87 88 <body> 89 90 <p>Test passes if the orange stripe is exactly as wide as the blue stripe and is horizontally positioned the same.</p> 91 92 <table> 93 94 <col></col> 95 <col></col> 96 <col id="test"></col> 97 <col></col> 98 99 <tr> 100 <td></td> 101 <td></td> 102 <td id="third-cell">col</td> 103 <td></td> 104 </tr> 105 106 </table> 107 108 <div id="reference">ref</div> 109 110 </body> 111 </html>