summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/CSS2/positioning/left-offset-percentage-002.xht
blob: 425d31c30f4916bf26a914aa9fff438dbc2cce62 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

 <head>

  <title>CSS Test: position absolute - left offset percentage and inherit</title>

  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
  <link rel="help" title="6.2.1 The 'inherit' value" href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit" />
  <link rel="help" href="http://www.w3.org/TR/css-cascade-3/#inherit" />
  <link rel="help" href="http://www.w3.org/TR/css-cascade-4/#inherit" />
  <link rel="help" title="9.3.2 Box offsets: 'top', 'right', 'bottom', 'left'" href="http://www.w3.org/TR/CSS21/visuren.html#position-props" />
  <link rel="match" href="left-offset-percentage-002-ref.xht" />
  <meta content="'left: inherit' makes the left property take the same computed value as the left property for the element's parent; in the case of a percentage value, the computed value is the specified percentage value. 'left: [percentage]' refers to width of containing block." name="assert" />

  <style type="text/css"><![CDATA[
  div {position: absolute;}

  #grand-parent-abs-pos
  {
  height: 400px;
  width: 600px;
  }

  #red-abs-pos-overlapped
  {
  background-color: red;
  color: white;
  height: 100px;
  left: 300px;
  top: 100px;
  width: 100px;
  }

  #parent-abs-pos
  {
  height: 0px;
  left: 50%; /* 50% x 600px == 300px */
  /* 'left: [percentage]' refers to width of containing block. */
  top: 25%; /* 25% x 400px == 100px */
  /* 'top: [percentage]' refers to height of containing block. */
  width: 0px;
  }

  #green-child-abs-pos-inherit-overlapping
  {
  background-color: green;
  left: inherit;
  /*
  =====================================
  left: inherit should resolve as left: 50% because
  "the property takes the same computed value as the
  property for the element's parent"
  CSS 2.1, section 6.2.1 The 'inherit' value
  http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit
  and
  "Computed value: (...) if specified as a percentage, [then]
  the specified [percentage] value"
  http://www.w3.org/TR/CSS21/visuren.html#position-props

  So, the left offset of #green-child-abs-pos-inherit-overlapping
  should be 50%, which is 50% of the width of its containing
  block (#parent-abs-pos) which is 0px.
  =====================================
  */
  top: 0px;
  height: 100px;
  width: 100px;
  }
  ]]></style>

 </head>

 <body>

  <p>Test passes if there is a filled green square and <strong>no red</strong>.</p>

  <div id="grand-parent-abs-pos">
    <div id="red-abs-pos-overlapped">test FAILED</div>
    <div id="parent-abs-pos">
      <div id="green-child-abs-pos-inherit-overlapping"></div>
    </div>
  </div>

 </body>
</html>