relpos-calcs-005

Relative Positioning - overconstrained left = -right (LTR)

WeasyPrint

This browser

Assertion
For a relatively positioned element in an LTR containing block, if neither 'left' nor 'right' is 'auto', used value of 'right' is minus the value of 'left'.

Source

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 2 <html>
 3   <head>
 4     <title>CSS Test: Relative Positioning - overconstrained left = -right (LTR)</title>
 5     <link rel="author" title="Elika J. Etemad" href="http://fantasai.inkedblade.net/contact">
 6     <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#relative-positioning">
 7     <meta name="flags" content="">
 8     <meta name="assert" content="For a relatively positioned element in an LTR       containing block, if neither 'left' nor 'right' is 'auto', used value of       'right' is minus the value of 'left'.">
 9     <style type="text/css">
10         div {
11             height: 120px;
12             width: 80px;
13             direction: rtl;
14             margin-right: auto;
15         }
16         .container {
17             direction: ltr; /* only set LTR on the containing block in question */
18         }
19         .outer {
20             background: green;
21             position: relative;
22             left: 50%;
23             right: 50%;
24         }
25         .inner {
26             background: green;
27             position: relative;
28             right: inherit; /* using inheritance to test computed vs. used */
29         }
30         .control {
31           background: red;
32           margin-bottom: -120px;
33           width: 120px;
34         }
35     </style>
36   </head>
37   <body>
38     <p>There must be a green box below and no red.</p>
39     <div class="control"></div>
40     <div class="container" dir="ltr">
41       <div class="outer" dir="rtl">
42         <div class="inner"></div>
43       </div>
44     </div>
45   </body>
46 </html>