/
ratio.scss
50 lines (41 loc) · 1.08 KB
/
ratio.scss
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
/* ==========================================================================
#BOLT RATIO OBJECT
========================================================================== */
@import '@bolt/core';
bolt-ratio {
display: block;
position: relative;
width: 100%;
@include bolt-css-vars((
--aspect-ratio: 1/1,
));
@supports (--custom:property) {
padding-bottom: 0 !important; // workaround to ensure browsers with CSS custom prop support don't use the inline padding bottom added via Twig before the JS kicks in
&:before {
content: '';
display: block;
padding-bottom: calc(100% / (var(--aspect-ratio)));
}
}
}
/**
* 1. Fallback selector if JS isn't disabled, but hasn't kicked in yet.
* 2. Fallback selector for browsers not supporting ::slotted(*) selector
*/
bolt-ratio > * {
position: absolute;
top: 0;
left: 0;
width: 100%;
min-width: 100%; // workaround for content w/ hard-coded height & width
min-height: 100%;
}
:host {
height: auto;
}
:host ::slotted(*) {
position: absolute;
top: 0;
left: 0;
width: 100%;
}