1 | // Notes on the classes:
|
---|
2 | //
|
---|
3 | // 1. .carousel.pointer-event should ideally be pan-y (to allow for users to scroll vertically)
|
---|
4 | // even when their scroll action started on a carousel, but for compatibility (with Firefox)
|
---|
5 | // we're preventing all actions instead
|
---|
6 | // 2. The .carousel-item-start and .carousel-item-end is used to indicate where
|
---|
7 | // the active slide is heading.
|
---|
8 | // 3. .active.carousel-item is the current slide.
|
---|
9 | // 4. .active.carousel-item-start and .active.carousel-item-end is the current
|
---|
10 | // slide in its in-transition state. Only one of these occurs at a time.
|
---|
11 | // 5. .carousel-item-next.carousel-item-start and .carousel-item-prev.carousel-item-end
|
---|
12 | // is the upcoming slide in transition.
|
---|
13 |
|
---|
14 | .carousel {
|
---|
15 | position: relative;
|
---|
16 | }
|
---|
17 |
|
---|
18 | .carousel.pointer-event {
|
---|
19 | touch-action: pan-y;
|
---|
20 | }
|
---|
21 |
|
---|
22 | .carousel-inner {
|
---|
23 | position: relative;
|
---|
24 | width: 100%;
|
---|
25 | overflow: hidden;
|
---|
26 | @include clearfix();
|
---|
27 | }
|
---|
28 |
|
---|
29 | .carousel-item {
|
---|
30 | position: relative;
|
---|
31 | display: none;
|
---|
32 | float: left;
|
---|
33 | width: 100%;
|
---|
34 | margin-right: -100%;
|
---|
35 | backface-visibility: hidden;
|
---|
36 | @include transition($carousel-transition);
|
---|
37 | }
|
---|
38 |
|
---|
39 | .carousel-item.active,
|
---|
40 | .carousel-item-next,
|
---|
41 | .carousel-item-prev {
|
---|
42 | display: block;
|
---|
43 | }
|
---|
44 |
|
---|
45 | .carousel-item-next:not(.carousel-item-start),
|
---|
46 | .active.carousel-item-end {
|
---|
47 | transform: translateX(100%);
|
---|
48 | }
|
---|
49 |
|
---|
50 | .carousel-item-prev:not(.carousel-item-end),
|
---|
51 | .active.carousel-item-start {
|
---|
52 | transform: translateX(-100%);
|
---|
53 | }
|
---|
54 |
|
---|
55 |
|
---|
56 | //
|
---|
57 | // Alternate transitions
|
---|
58 | //
|
---|
59 |
|
---|
60 | .carousel-fade {
|
---|
61 | .carousel-item {
|
---|
62 | opacity: 0;
|
---|
63 | transition-property: opacity;
|
---|
64 | transform: none;
|
---|
65 | }
|
---|
66 |
|
---|
67 | .carousel-item.active,
|
---|
68 | .carousel-item-next.carousel-item-start,
|
---|
69 | .carousel-item-prev.carousel-item-end {
|
---|
70 | z-index: 1;
|
---|
71 | opacity: 1;
|
---|
72 | }
|
---|
73 |
|
---|
74 | .active.carousel-item-start,
|
---|
75 | .active.carousel-item-end {
|
---|
76 | z-index: 0;
|
---|
77 | opacity: 0;
|
---|
78 | @include transition(opacity 0s $carousel-transition-duration);
|
---|
79 | }
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | //
|
---|
84 | // Left/right controls for nav
|
---|
85 | //
|
---|
86 |
|
---|
87 | .carousel-control-prev,
|
---|
88 | .carousel-control-next {
|
---|
89 | position: absolute;
|
---|
90 | top: 0;
|
---|
91 | bottom: 0;
|
---|
92 | z-index: 1;
|
---|
93 | // Use flex for alignment (1-3)
|
---|
94 | display: flex; // 1. allow flex styles
|
---|
95 | align-items: center; // 2. vertically center contents
|
---|
96 | justify-content: center; // 3. horizontally center contents
|
---|
97 | width: $carousel-control-width;
|
---|
98 | padding: 0;
|
---|
99 | color: $carousel-control-color;
|
---|
100 | text-align: center;
|
---|
101 | background: none;
|
---|
102 | border: 0;
|
---|
103 | opacity: $carousel-control-opacity;
|
---|
104 | @include transition($carousel-control-transition);
|
---|
105 |
|
---|
106 | // Hover/focus state
|
---|
107 | &:hover,
|
---|
108 | &:focus {
|
---|
109 | color: $carousel-control-color;
|
---|
110 | text-decoration: none;
|
---|
111 | outline: 0;
|
---|
112 | opacity: $carousel-control-hover-opacity;
|
---|
113 | }
|
---|
114 | }
|
---|
115 | .carousel-control-prev {
|
---|
116 | left: 0;
|
---|
117 | background-image: if($enable-gradients, linear-gradient(90deg, rgba($black, .25), rgba($black, .001)), null);
|
---|
118 | }
|
---|
119 | .carousel-control-next {
|
---|
120 | right: 0;
|
---|
121 | background-image: if($enable-gradients, linear-gradient(270deg, rgba($black, .25), rgba($black, .001)), null);
|
---|
122 | }
|
---|
123 |
|
---|
124 | // Icons for within
|
---|
125 | .carousel-control-prev-icon,
|
---|
126 | .carousel-control-next-icon {
|
---|
127 | display: inline-block;
|
---|
128 | width: $carousel-control-icon-width;
|
---|
129 | height: $carousel-control-icon-width;
|
---|
130 | background-repeat: no-repeat;
|
---|
131 | background-position: 50%;
|
---|
132 | background-size: 100% 100%;
|
---|
133 | }
|
---|
134 |
|
---|
135 | .carousel-control-prev-icon {
|
---|
136 | background-image: escape-svg($carousel-control-prev-icon-bg) #{"/*rtl:" + escape-svg($carousel-control-next-icon-bg) + "*/"};
|
---|
137 | }
|
---|
138 | .carousel-control-next-icon {
|
---|
139 | background-image: escape-svg($carousel-control-next-icon-bg) #{"/*rtl:" + escape-svg($carousel-control-prev-icon-bg) + "*/"};
|
---|
140 | }
|
---|
141 |
|
---|
142 | // Optional indicator pips/controls
|
---|
143 | //
|
---|
144 | // Add a container (such as a list) with the following class and add an item (ideally a focusable control,
|
---|
145 | // like a button) with data-bs-target for each slide your carousel holds.
|
---|
146 |
|
---|
147 | .carousel-indicators {
|
---|
148 | position: absolute;
|
---|
149 | right: 0;
|
---|
150 | bottom: 0;
|
---|
151 | left: 0;
|
---|
152 | z-index: 2;
|
---|
153 | display: flex;
|
---|
154 | justify-content: center;
|
---|
155 | padding: 0;
|
---|
156 | // Use the .carousel-control's width as margin so we don't overlay those
|
---|
157 | margin-right: $carousel-control-width;
|
---|
158 | margin-bottom: 1rem;
|
---|
159 | margin-left: $carousel-control-width;
|
---|
160 |
|
---|
161 | [data-bs-target] {
|
---|
162 | box-sizing: content-box;
|
---|
163 | flex: 0 1 auto;
|
---|
164 | width: $carousel-indicator-width;
|
---|
165 | height: $carousel-indicator-height;
|
---|
166 | padding: 0;
|
---|
167 | margin-right: $carousel-indicator-spacer;
|
---|
168 | margin-left: $carousel-indicator-spacer;
|
---|
169 | text-indent: -999px;
|
---|
170 | cursor: pointer;
|
---|
171 | background-color: $carousel-indicator-active-bg;
|
---|
172 | background-clip: padding-box;
|
---|
173 | border: 0;
|
---|
174 | // Use transparent borders to increase the hit area by 10px on top and bottom.
|
---|
175 | border-top: $carousel-indicator-hit-area-height solid transparent;
|
---|
176 | border-bottom: $carousel-indicator-hit-area-height solid transparent;
|
---|
177 | opacity: $carousel-indicator-opacity;
|
---|
178 | @include transition($carousel-indicator-transition);
|
---|
179 | }
|
---|
180 |
|
---|
181 | .active {
|
---|
182 | opacity: $carousel-indicator-active-opacity;
|
---|
183 | }
|
---|
184 | }
|
---|
185 |
|
---|
186 |
|
---|
187 | // Optional captions
|
---|
188 | //
|
---|
189 | //
|
---|
190 |
|
---|
191 | .carousel-caption {
|
---|
192 | position: absolute;
|
---|
193 | right: (100% - $carousel-caption-width) * .5;
|
---|
194 | bottom: $carousel-caption-spacer;
|
---|
195 | left: (100% - $carousel-caption-width) * .5;
|
---|
196 | padding-top: $carousel-caption-padding-y;
|
---|
197 | padding-bottom: $carousel-caption-padding-y;
|
---|
198 | color: $carousel-caption-color;
|
---|
199 | text-align: center;
|
---|
200 | }
|
---|
201 |
|
---|
202 | // Dark mode carousel
|
---|
203 |
|
---|
204 | @mixin carousel-dark() {
|
---|
205 | .carousel-control-prev-icon,
|
---|
206 | .carousel-control-next-icon {
|
---|
207 | filter: $carousel-dark-control-icon-filter;
|
---|
208 | }
|
---|
209 |
|
---|
210 | .carousel-indicators [data-bs-target] {
|
---|
211 | background-color: $carousel-dark-indicator-active-bg;
|
---|
212 | }
|
---|
213 |
|
---|
214 | .carousel-caption {
|
---|
215 | color: $carousel-dark-caption-color;
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | .carousel-dark {
|
---|
220 | @include carousel-dark();
|
---|
221 | }
|
---|
222 |
|
---|
223 | @if $enable-dark-mode {
|
---|
224 | @include color-mode(dark) {
|
---|
225 | @if $color-mode-type == "media-query" {
|
---|
226 | .carousel {
|
---|
227 | @include carousel-dark();
|
---|
228 | }
|
---|
229 | } @else {
|
---|
230 | .carousel,
|
---|
231 | &.carousel {
|
---|
232 | @include carousel-dark();
|
---|
233 | }
|
---|
234 | }
|
---|
235 | }
|
---|
236 | }
|
---|