summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/cssom-view/offsetTop-offsetLeft-nested-offsetParents.html
blob: e9446708d35ef243789892da585ed9990ad4cec4 (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>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://drafts.csswg.org/cssom-view-1/#dom-htmlelement-offsettop">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<style>
.square {
  width: 10px;
  height: 10px;
  background-color: red;
}
#one {
  position: absolute;
  top: 10px;
  left: 10px;
}
#two {
  position: absolute;
  top: 50px;
  left: 50px;
}
span.square {
  display: inline-block;
}
</style>

<div id=one class=square>
  <div id=two class=square>
    <div class=square></div>
    <span class=square></span><span id=target></span>
  </div>
</div>

<script>
test(() => {
  assert_equals(target.offsetTop, 10, 'target.offsetTop');
  assert_equals(target.offsetLeft, 10, 'target.offsetLeft');
}, 'Verifies that offsetTop and offsetLeft only go up one offsetParent when there are multiple nested offsetParents.');
</script>