_carousel.scss 5.07 KB
Newer Older
1
2
// Notes on the classes:
//
patrickhlauke's avatar
patrickhlauke committed
3
4
5
6
// 1. .carousel.pointer-event should ideally be pan-y (to allow for users to scroll vertically)
//    even when their scroll action started on a carousel, but for compatibility (with Firefox)
//    we're preventing all actions instead
// 2. The .carousel-item-left and .carousel-item-right is used to indicate where
7
//    the active slide is heading.
patrickhlauke's avatar
patrickhlauke committed
8
9
// 3. .active.carousel-item is the current slide.
// 4. .active.carousel-item-left and .active.carousel-item-right is the current
10
//    slide in its in-transition state. Only one of these occurs at a time.
patrickhlauke's avatar
patrickhlauke committed
11
// 5. .carousel-item-next.carousel-item-left and .carousel-item-prev.carousel-item-right
12
13
//    is the upcoming slide in transition.

14
.carousel {
15
16
  position: relative;
}
17

Johann-S's avatar
Johann-S committed
18
.carousel.pointer-event {
patrickhlauke's avatar
patrickhlauke committed
19
  touch-action: none;
Johann-S's avatar
Johann-S committed
20
21
}

22
.carousel-inner {
Mark Otto's avatar
Mark Otto committed
23
  position: relative;
24
  width: 100%;
25
  overflow: hidden;
Mark Otto's avatar
Mark Otto committed
26
}
27

Mark Otto's avatar
Mark Otto committed
28
29
30
.carousel-item {
  position: relative;
  display: none;
31
  align-items: center;
Mark Otto's avatar
Mark Otto committed
32
  width: 100%;
Mark Otto's avatar
Mark Otto committed
33
34
  backface-visibility: hidden;
  perspective: 1000px;
Mark Otto's avatar
Mark Otto committed
35
}
36

Mark Otto's avatar
Mark Otto committed
37
38
39
.carousel-item.active,
.carousel-item-next,
.carousel-item-prev {
Mark Otto's avatar
Mark Otto committed
40
  display: block;
domq's avatar
domq committed
41
  @include transition($carousel-transition);
Mark Otto's avatar
Mark Otto committed
42
}
43

Mark Otto's avatar
Mark Otto committed
44
45
.carousel-item-next,
.carousel-item-prev {
Mark Otto's avatar
Mark Otto committed
46
47
48
  position: absolute;
  top: 0;
}
49

Mark Otto's avatar
Mark Otto committed
50
51
.carousel-item-next.carousel-item-left,
.carousel-item-prev.carousel-item-right {
52
53
54
55
56
  transform: translateX(0);

  @supports (transform-style: preserve-3d) {
    transform: translate3d(0, 0, 0);
  }
Mark Otto's avatar
Mark Otto committed
57
}
58

Mark Otto's avatar
Mark Otto committed
59
60
.carousel-item-next,
.active.carousel-item-right {
61
62
63
64
65
  transform: translateX(100%);

  @supports (transform-style: preserve-3d) {
    transform: translate3d(100%, 0, 0);
  }
Mark Otto's avatar
Mark Otto committed
66
}
Mark Otto's avatar
Mark Otto committed
67

Mark Otto's avatar
Mark Otto committed
68
69
.carousel-item-prev,
.active.carousel-item-left {
70
71
72
73
74
  transform: translateX(-100%);

  @supports (transform-style: preserve-3d) {
    transform: translate3d(-100%, 0, 0);
  }
75
}
76

Mark Otto's avatar
Mark Otto committed
77

78
79
80
81
82
83
84
85
//
// Alternate transitions
//

.carousel-fade {
  .carousel-item {
    opacity: 0;
    transition-property: opacity;
86
    transform: none;
87
88
89
90
91
  }

  .carousel-item.active,
  .carousel-item-next.carousel-item-left,
  .carousel-item-prev.carousel-item-right {
92
    z-index: 1;
93
94
95
96
97
    opacity: 1;
  }

  .active.carousel-item-left,
  .active.carousel-item-right {
98
    z-index: 0;
99
    opacity: 0;
100
    @include transition(0s $carousel-transition-duration opacity);
101
102
103
104
  }
}


Mark Otto's avatar
Mark Otto committed
105
//
106
// Left/right controls for nav
Mark Otto's avatar
Mark Otto committed
107
//
108

109
110
.carousel-control-prev,
.carousel-control-next {
111
  position: absolute;
Mark Otto's avatar
Mark Otto committed
112
113
  top: 0;
  bottom: 0;
114
  z-index: 1;
Mark Otto's avatar
Mark Otto committed
115
116
  // Use flex for alignment (1-3)
  display: flex; // 1. allow flex styles
Mark Otto's avatar
linting    
Mark Otto committed
117
118
  align-items: center; // 2. vertically center contents
  justify-content: center; // 3. horizontally center contents
Mark Otto's avatar
Mark Otto committed
119
120
  width: $carousel-control-width;
  color: $carousel-control-color;
121
  text-align: center;
122
  opacity: $carousel-control-opacity;
123
  @include transition($carousel-control-transition);
124

125
  // Hover/focus state
126
  @include hover-focus {
Mark Otto's avatar
Mark Otto committed
127
    color: $carousel-control-color;
128
    text-decoration: none;
129
    outline: 0;
130
    opacity: $carousel-control-hover-opacity;
131
  }
Mark Otto's avatar
Mark Otto committed
132
}
133
134
.carousel-control-prev {
  left: 0;
Mark Otto's avatar
Mark Otto committed
135
  @if $enable-gradients {
136
    background: linear-gradient(90deg, rgba($black, .25), rgba($black, .001));
Mark Otto's avatar
Mark Otto committed
137
  }
138
139
140
}
.carousel-control-next {
  right: 0;
Mark Otto's avatar
Mark Otto committed
141
  @if $enable-gradients {
142
    background: linear-gradient(270deg, rgba($black, .25), rgba($black, .001));
Mark Otto's avatar
Mark Otto committed
143
  }
144
}
Mark Otto's avatar
Mark Otto committed
145

146
147
148
// Icons for within
.carousel-control-prev-icon,
.carousel-control-next-icon {
Mark Otto's avatar
Mark Otto committed
149
  display: inline-block;
Mark Otto's avatar
Mark Otto committed
150
151
  width: $carousel-control-icon-width;
  height: $carousel-control-icon-width;
152
153
  background: transparent no-repeat center center;
  background-size: 100% 100%;
Mark Otto's avatar
Mark Otto committed
154
}
155
156
.carousel-control-prev-icon {
  background-image: $carousel-control-prev-icon-bg;
Mark Otto's avatar
Mark Otto committed
157
}
158
159
.carousel-control-next-icon {
  background-image: $carousel-control-next-icon-bg;
160
}
Mark Otto's avatar
Mark Otto committed
161

Mark Otto's avatar
Mark Otto committed
162

163
// Optional indicator pips
164
//
Quy's avatar
Quy committed
165
// Add an ordered list with the following class and add a list item for each
166
167
// slide your carousel holds.

168
169
.carousel-indicators {
  position: absolute;
170
  right: 0;
171
  bottom: 0;
172
  left: 0;
Mark Otto's avatar
Mark Otto committed
173
  z-index: 15;
Mark Otto's avatar
Mark Otto committed
174
175
  display: flex;
  justify-content: center;
Quy's avatar
Quy committed
176
  padding-left: 0; // override <ol> default
177
178
179
  // Use the .carousel-control's width as margin so we don't overlay those
  margin-right: $carousel-control-width;
  margin-left: $carousel-control-width;
180
  list-style: none;
181
182

  li {
183
    box-sizing: content-box;
Mark Otto's avatar
Mark Otto committed
184
    flex: 0 1 auto;
185
    width: $carousel-indicator-width;
Mark Otto's avatar
Mark Otto committed
186
    height: $carousel-indicator-height;
Mark Otto's avatar
Mark Otto committed
187
188
    margin-right: $carousel-indicator-spacer;
    margin-left: $carousel-indicator-spacer;
189
    text-indent: -999px;
190
    cursor: pointer;
191
    background-color: $carousel-indicator-active-bg;
192
193
194
195
    background-clip: padding-box;
    // Use transparent borders to increase the hit area by 10px on top and bottom.
    border-top: $carousel-indicator-hit-area-height solid transparent;
    border-bottom: $carousel-indicator-hit-area-height solid transparent;
196
197
    opacity: .5;
    @include transition($carousel-indicator-transition);
198
  }
199

200
  .active {
201
    opacity: 1;
202
203
  }
}
204

Mark Otto's avatar
Mark Otto committed
205

206
// Optional captions
Mark Otto's avatar
Mark Otto committed
207
//
Quy's avatar
Quy committed
208
//
Mark Otto's avatar
Mark Otto committed
209

210
211
.carousel-caption {
  position: absolute;
212
  right: ((100% - $carousel-caption-width) / 2);
213
  bottom: 20px;
214
  left: ((100% - $carousel-caption-width) / 2);
215
  z-index: 10;
216
217
  padding-top: 20px;
  padding-bottom: 20px;
Mark Otto's avatar
Mark Otto committed
218
  color: $carousel-caption-color;
219
  text-align: center;
220
}