| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/st
rict.dtd"> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>CSS Test: Absolutely positioned non-replaced elements when both '
margin-left' and 'margin-right' are set to 'auto' and direction is left-to-right
</title> | |
| 5 <link rel="author" title="Microsoft" href="http://www.microsoft.com/"> | |
| 6 <link rel="help" href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-r
eplaced-width"> | |
| 7 <meta name="flags" content="ahem"> | |
| 8 <script src="../../resources/ahem.js"></script> | |
| 9 <meta name="assert" content="When direction is 'ltr' and 'left', 'width'
and 'right' are not 'auto', solve for 'margin-right' and 'margin-left' to equal
values. If this would make 'margin-left' and 'margin-right' negative, then set
'margin-left' to zero and solve for 'margin-right'."> | |
| 10 <style type="text/css"> | |
| 11 #div1 | |
| 12 { | |
| 13 border: solid black; | |
| 14 direction: ltr; | |
| 15 height: 2in; | |
| 16 position: relative; | |
| 17 width: 2in; | |
| 18 } | |
| 19 div div | |
| 20 { | |
| 21 background: red; | |
| 22 color: blue; | |
| 23 font: 1in/1em Ahem; | |
| 24 left: 1in; | |
| 25 margin-left: auto; | |
| 26 margin-right: auto; | |
| 27 position: absolute; | |
| 28 right: 1in; | |
| 29 width: 1in; | |
| 30 } | |
| 31 /* | |
| 32 left : 1in | |
| 33 + margin-left : solve (auto) | |
| 34 + border-left-width : 0 | |
| 35 + padding-left : 0 | |
| 36 + width : 1in | |
| 37 + padding-right : 0 | |
| 38 + border-right-width : 0 | |
| 39 + margin-right : solve (auto) | |
| 40 + right : 1in | |
| 41 ==================================== | |
| 42 width of containing block : 2in | |
| 43 | |
| 44 So, margin-left and margin-right would be each -0.5in at this point. | |
| 45 | |
| 46 "...unless this would make them (the two margins) negative in which
case when direction of the containing block is 'ltr' ('rtl'), set 'margin-left'
('margin-right') to zero and solve for 'margin-right' ('margin-left')." | |
| 47 | |
| 48 So, under such extra constraint, 'margin-left' must become 0 and 'ma
rgin-right' must become -1in. | |
| 49 */ | |
| 50 </style> | |
| 51 </head> | |
| 52 <body> | |
| 53 <p>Test passes if the blue box fills the upper-right corner of the black
box and there is no red visible on the page.</p> | |
| 54 <div id="div1"> | |
| 55 <div>X</div> | |
| 56 </div> | |
| 57 </body> | |
| 58 </html> | |
| OLD | NEW |