blob: 79c29f4e87bf7c14572e51757c258945eb0c8c6e (
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
|
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos" />
<meta name="assert" content="Position sticky with a fractional offset should not show a gap" />
<link rel="match" href="position-sticky-fractional-offset-ref.html" />
<style>
.sticky-container {
width: 100px;
height: 100px;
overflow-y: scroll;
background: red;
display: inline-block;
}
.sticky {
position: sticky;
top: 0;
height: 50px;
background: lightgreen;
}
.force-scroll {
height: 300px;
background: lightgreen;
}
</style>
<div class="sticky-container">
<div style="height: 10.10px;"></div>
<div class="sticky"></div>
<div class="force-scroll"></div>
</div>
<div class="sticky-container">
<div style="height: 10.25px;"></div>
<div class="sticky"></div>
<div class="force-scroll"></div>
</div>
<div class="sticky-container">
<div style="height: 10.50px;"></div>
<div class="sticky"></div>
<div class="force-scroll"></div>
</div>
<div class="sticky-container">
<div style="height: 10.75px;"></div>
<div class="sticky"></div>
<div class="force-scroll"></div>
</div>
<div class="sticky-container">
<div style="height: 10.90px;"></div>
<div class="sticky"></div>
<div class="force-scroll"></div>
</div>
<script>
window.onload = function() {
// Start with all containers scrolled to the top.
var containers = document.getElementsByClassName('sticky-container');
for (let i = 0; i < containers.length; i++) {
containers[i].scrollTo(0, 0);
}
// Wait for a full frame, then scroll all containers down so the sticky
// elements are stuck to the container. There should be no visible gap
// where the container's red background color is visible.
requestAnimationFrame(() => {
requestAnimationFrame(() => {
for (let i = 0; i < containers.length; i++) {
containers[i].scrollTo(0, 20);
}
document.documentElement.classList.remove('reftest-wait');
});
});
};
</script>
</html>
|