-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathvariable-reference-perspective-origin.html
More file actions
69 lines (63 loc) · 1.9 KB
/
variable-reference-perspective-origin.html
File metadata and controls
69 lines (63 loc) · 1.9 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Variables: perspective-origin with var() references</title>
<link rel="help" href="https://drafts.csswg.org/css-transforms-2/#perspective-origin-property">
<link rel="help" href="https://drafts.csswg.org/css-variables-2/">
<meta name="assert" content="perspective-origin correctly resolves CSS variables in both value positions">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.target {
width: 200px;
height: 200px;
perspective: 800px;
}
</style>
</head>
<body>
<script>
function test_perspective_origin_var(style, expected, description) {
test(() => {
const div = document.createElement('div');
div.className = 'target';
div.setAttribute('style', style);
document.body.appendChild(div);
assert_equals(getComputedStyle(div).perspectiveOrigin, expected);
div.remove();
}, description);
}
test_perspective_origin_var(
'--x: 0%; perspective-origin: var(--x) 50%',
'0px 100px',
'var() as first value of perspective-origin'
);
test_perspective_origin_var(
'--y: 0%; perspective-origin: 50% var(--y)',
'100px 0px',
'var() as second value of perspective-origin'
);
test_perspective_origin_var(
'--x: 10%; --y: 20%; perspective-origin: var(--x) var(--y)',
'20px 40px',
'var() as both values of perspective-origin'
);
test_perspective_origin_var(
'--pos: 25%; perspective-origin: var(--pos) var(--pos)',
'50px 50px',
'same var() for both values of perspective-origin'
);
test_perspective_origin_var(
'--y: top; perspective-origin: 50% var(--y)',
'100px 0px',
'var() as second value with keyword'
);
test_perspective_origin_var(
'--x: left; perspective-origin: var(--x) 50%',
'0px 100px',
'var() as first value with keyword'
);
</script>
</body>
</html>