-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixed-in-transformed-layer.html
More file actions
70 lines (70 loc) · 1.28 KB
/
fixed-in-transformed-layer.html
File metadata and controls
70 lines (70 loc) · 1.28 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title></title>
<style>
html, body {
margin: 0;
padding: 0;
background: black;
}
.fixed {
position: fixed;
}
#outer {
background: yellow;
position: relative;
top: 30px;
height: 300px;
overflow-y: auto;
}
#inner {
color: white;
background: blue;
top: 60px;
left: 60px;
right: 60px;
bottom: 60px;
}
#toggle-translate0 {
float :right;
}
.translate0 {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.translate0::before {
content: 'translate3d(0,0,0)';
}
</style>
</head>
<body>
<div class="" id="outer">
<button id="toggle-translate0">Toggle</button>
Outer <div>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
<p>10</p>
<div class="fixed" id="inner">
Fixed: top/left: 60px
</div>
</div>
<script>
var inner = document.querySelector('#inner')
var outer = document.querySelector('#outer')
document.querySelector('#toggle-translate0').addEventListener('click', function () {
var cls = /translate0/.test(outer.getAttribute('class')) ? '' : 'translate0'
outer.setAttribute('class', cls)
})
</script>
</body>
</html>