forked from supple-kit/supple-css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_index.scss
75 lines (57 loc) · 1.8 KB
/
_index.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
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
/* =========================================================================
objects.aspect-ratio
For use with multi-media embeds such as videos, images or slideshows,
that need to retain a specific aspect ratio but adapt to elements
of variable widths.
========================================================================= */
/* Use rules
`@use` everything you need here from other files. Variables, mixins &
other includes.
========================================================================= */
/**
* Forward the variables to the parent stylesheet
*/
@forward './variables';
/**
* Use the settings & tools in this sheet
*/
@use 'sass:meta';
@use './variables';
@use '../../settings/defaults';
/* Internal variables
========================================================================= */
$selector: '> *';
@if (defaults.$css-modules) {
$selector: ':global(#{$selector})';
}
/* Module
========================================================================= */
/**
* 1. Default cropping is a perfect square, in you own modules you can override
* the ratio like this: (16/9)
*/
.o-aspect-ratio {
--ratio: (1/1); /* [1] */
position: relative;
display: block;
block-size: 0;
padding-block-end: calc(100% / var(--ratio));
#{$selector} {
position: absolute;
inline-size: 100%;
block-size: 100%;
}
}
/* Common ratio modifiers, for use in browsers without
custom-property support
========================================================================= */
@each $ratio in variables.$ratios {
@each $a, $b in $ratio {
@if (meta.type-of($a) != number or meta.type-of($b) != number) {
@error '`#{$a}` and `#{$b}` need to be numbers.';
}
.o-aspect-ratio--#{$a}by#{$b} {
--ratio: (#{$a}/#{$b});
}
}
}