-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_object.ratio.scss
121 lines (84 loc) · 2.79 KB
/
_object.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// =============================================================================
//
// Name: Ratio
//
// Description: For use with media embeds - suck as videos, slideshows, or
// even images that need to retain specific aspect ratio.
//
// Block: `o-ratio`
//
// Element: `o-ratio__item`
//
// Modifiers: `o-ratio--3by1`
// `o-ratio--2by1`
// `o-ratio--16by9`
// `o-ratio--4by3`
//
// Markup:
//
// <div class="o-ratio o-ratio--16by9">
// <iframe class="o-ratio__item" src="..."></iframe>
// </div>
//
// <figure class="o-ratio o-ratio--4by3">
// <img class="ratio__item" src="path/to/image.jpg" alt="">
// </figure>
//
// =============================================================================
// Variables
// =============================================================================
// Predefine the variables below in order to alter and enable specific features.
$tree-ratio-namespace: $tree-namespace !default;
$tree-enable-ratio--3by1: false !default;
$tree-enable-ratio--2by1: false !default;
$tree-enable-ratio--16by9: false !default;
$tree-enable-ratio--4by3: false !default;
// =============================================================================
// Block: `o-ratio`
// =============================================================================
// 1. Default aspect ratio is 1:1.
.#{$tree-ratio-namespace}o-ratio {
position: relative;
display: block;
height: 0;
padding-bottom: 100%; // [1]
overflow: hidden;
}
// Element: `o-ratio__item`
// =========================================================================
.#{$tree-ratio-namespace}o-ratio__item {
position: absolute;
top: 0;
left: 0;
bottom: 0;
height: 100%;
width: 100%;
}
@if ($tree-enable-ratio--3by1 == true) {
// Modifier: `o-ratio--3by1`
// =========================================================================
.#{$tree-ratio-namespace}o-ratio--3by1 {
padding-bottom: 33.33333%;
}
}
@if ($tree-enable-ratio--2by1 == true) {
// Modifier: `o-ratio--2by1`
// =========================================================================
.#{$tree-ratio-namespace}o-ratio--2by1 {
padding-bottom: 50%;
}
}
@if ($tree-enable-ratio--16by9 == true) {
// Modifier: `o-ratio--16by9`
// =========================================================================
.#{$tree-ratio-namespace}o-ratio--16by9 {
padding-bottom: 56.25%;
}
}
@if ($tree-enable-ratio--4by3 == true) {
// Modifier: `o-ratio--4by3`
// =========================================================================
.#{$tree-ratio-namespace}o-ratio--4by3 {
padding-bottom: 75%;
}
}