-
Notifications
You must be signed in to change notification settings - Fork 0
/
image-comparison.css
93 lines (83 loc) · 2.34 KB
/
image-comparison.css
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
.imgcompare {
--ar: var( --_w ) / var( --_h );
--_w: 16;
--_h: 9;
--_bg: var( --o-imgcompare-background, #ddd );
--_thumb-bg: var( --o-imgcompare-thumbBackground, #333 );
--_thumb-bg-focus: var( --o-imgcompare-thumbBackgroundFocus, hsl( 0 0% 40% / .7 ) );
--_thumb-w: var( --o-imgcompare-thumbWidth, min( 5px, .3em ) );
display: grid;
aspect-ratio: var( --ar );
background: var( --_bg );
& > * {
grid-area: 1 / 1;
}
.before,
.after {
width: 100%;
height: 100%;
object-fit: cover;
}
.before {
clip-path: polygon( 0% 0%, var( --value ) 0%, var( --value ) 100%, 0% 100% );
}
.after {
clip-path: polygon( 100% 0%, var( --value ) 0%, var( --value ) 100%, 100% 100% );
}
.range,
.range::-webkit-slider-runnable-track,
.range::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
-webkit-tap-highlight-color: transparent;
}
.range {
box-sizing: border-box;
z-index: 1;
width: 100%;
height: 100%;
margin: 0;
font-family: inherit;
background-color: transparent;
outline: none;
cursor: ew-resize;
&::-webkit-slider-thumb {
appearance: none;
width: var( --_thumb-w );
height: 100%;
background-color: var( --_thumb-bg );
border: 0;
border-radius: 0;
}
&::-webkit-slider-runnable-track {
box-sizing: border-box;
background: transparent;
background-size: 100%;
height: 100%;
}
&::-moz-range-thumb {
appearance: none;
width: var( --_thumb-w );
height: 100%;
background: var( --_thumb-bg );
border: 0;
border-radius: 0;
}
&::-moz-range-track {
box-sizing: border-box;
background: transparent;
background-size: 100%;
}
}
.range:focus {
--_thumb-bg: var( --_thumb-bg-focus );
}
/* use this to highlight the 'drag bar' on focus more precisely
.range:focus::-webkit-slider-thumb {
background: var( --_thumb-bg-focus );
}
.range:focus::-moz-range-thumb {
background: var( --_thumb-bg-focus );
}
*/
}