summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/css2.1/20110323/absolute-non-replaced-width-003.htm
blob: ccb1a9e2b49bf81903d89378dea92f44c4fef8a8 (plain)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>CSS Test: Absolutely positioned non-replaced elements with 'margin-left' and 'margin-right' set to 'auto'</title>
        <link rel="author" title="Microsoft" href="http://www.microsoft.com/">
        <link rel="help" href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width">
        <meta name="flags" content="ahem">
        <script src="../../resources/ahem.js"></script>
        <meta name="assert" content="When 'left', 'width' and 'right' are not 'auto', set 'margin-left' and 'margin-right' to equal values.">
        <style type="text/css">
            #containingblock
            {
                border: solid black;
                height: 2in;
                position: relative;
                width: 4in;
            }
            div div
            {
                /* left + margin-left + border-left-width + padding-left + width + padding-right + border-right-width + margin-right + right = width of containing block */
                /* 1in + solve       + 0                 + 0            + 1in   + 0             + 0                  + solve        + -2in   = 4in */
                background: red;
                color: blue;
                font: 1in/1em Ahem;
                left: 1in;
                margin-left: auto; /* value is solved to 2in */
                margin-right: auto; /* value is solved to 2in */
                position: absolute;
                right: -2in;
                width: 1in;
            }
        </style>
    </head>
    <body>
        <p>Test passes if the blue square in in the upper-right corner of the black rectangle and there is no red visible on the page.</p>
        <div id="containingblock">
            <div>X</div>
        </div>
    </body>
</html>