summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-position/position-absolute-table-001.html
blob: c467ac480069caad4da5d65480b0d7b8a32dccfe (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<title>CSS Position Absolute: table width/height</title>
<link rel="author" href="mailto:atotic@google.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://www.w3.org/TR/css-position-3/#abs-non-replaced-width">
<meta name="assert" content="Table css width/height are different. Make sure absolute position respects the differences.">
<style>

.container {
  margin-bottom: 8px;
  position: relative;
  width: 300px;
  height: 220px;
  background: gray;
}
table {
  position: absolute;
  border: 10px solid green;
  width: 100px;
  height: 100px;
  background: yellow;
  right: 0;
  bottom: 0;
  padding: 10px;
  border-spacing: 0 0;
}
.contentbox {
  box-sizing: content-box;
  width: 60px;
  height: 60px;
}
td {
  padding: 0;
}

</style>
<p>Table css width/height are interpreted differently: they are the minimum width. Absolute positioning code should respect this.</p>
<div class="container">
  <table id="one">
    <td>t1</td>
  </table>
</div>
<div class="container">
  <table id="two">
    <td><div style="width:160px;height:160px;background:orange">div makes cell larger.</div></td>
  </table>
</div>
<div class="container">
  <table id="one-border" style="box-sizing: border-box">
    <td>t1</td>
  </table>
</div>
<div class="container">
  <table id="two-border" style="box-sizing: border-box">
    <td><div style="width:160px;height:160px;background:orange">div makes cell larger.</div></td>
  </table>
</div>
<div class="container">
  <table id="one-content" class="contentbox">
    <td>t1</td>
  </table>
</div>
<div class="container">
  <table id="two-content" class="contentbox">
    <td><div style="width:160px;height:160px;background:orange">div makes cell larger.</div></td>
  </table>
</div>
<script>
test(() => {
  let t = document.getElementById("one");
  assert_equals(t.offsetWidth, 100);
  assert_equals(t.offsetHeight, 100);
  assert_equals(t.parentNode.offsetHeight, t.offsetTop + t.offsetHeight, "bottom position is 0");
  assert_equals(t.parentNode.offsetWidth, t.offsetLeft + t.offsetWidth, "right position is 0");
}, 'table size is interpreted as border-box width by default');
test(() => {
  let t = document.getElementById("two");
  assert_equals(t.offsetWidth, 200);
  assert_equals(t.offsetHeight, 200);
  assert_equals(t.parentNode.offsetWidth, t.offsetLeft + t.offsetWidth, "right position is 0");
  assert_equals(t.parentNode.offsetHeight, t.offsetTop + t.offsetHeight, "bottom position is 0");
}, 'table size is interpreted as minimum width');
test(() => {
  let t = document.getElementById("one-border");
  assert_equals(t.offsetWidth, 100);
  assert_equals(t.offsetHeight, 100);
  assert_equals(t.parentNode.offsetHeight, t.offsetTop + t.offsetHeight, "bottom position is 0");
  assert_equals(t.parentNode.offsetWidth, t.offsetLeft + t.offsetWidth, "right position is 0");
}, 'table size border-box');
test(() => {
  let t = document.getElementById("two-border");
  assert_equals(t.offsetWidth, 200);
  assert_equals(t.offsetHeight, 200);
  assert_equals(t.parentNode.offsetWidth, t.offsetLeft + t.offsetWidth, "right position is 0");
  assert_equals(t.parentNode.offsetHeight, t.offsetTop + t.offsetHeight, "bottom position is 0");
}, 'table size border-box interpreted as minimum width');
test(() => {
  let t = document.getElementById("one-content");
  assert_equals(t.offsetWidth, 100);
  assert_equals(t.offsetHeight, 100);
  assert_equals(t.parentNode.offsetHeight, t.offsetTop + t.offsetHeight, "bottom position is 0");
  assert_equals(t.parentNode.offsetWidth, t.offsetLeft + t.offsetWidth, "right position is 0");
}, 'table size content-box');
test(() => {
  let t = document.getElementById("two-content");
  assert_equals(t.offsetWidth, 200);
  assert_equals(t.offsetHeight, 200);
  assert_equals(t.parentNode.offsetWidth, t.offsetLeft + t.offsetWidth, "right position is 0");
  assert_equals(t.parentNode.offsetHeight, t.offsetTop + t.offsetHeight, "bottom position is 0");
}, 'table size content-box interpreted as minimum width');
</script>