_carousel.scss 4.66 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 {
19
  touch-action: pan-y;
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;
26
  @include clearfix();
Mark Otto's avatar
Mark Otto committed
27
}
28

Mark Otto's avatar
Mark Otto committed
29
30
31
.carousel-item {
  position: relative;
  display: none;
32
  float: left;
Mark Otto's avatar
Mark Otto committed
33
  width: 100%;
34
  margin-right: -100%;
35
  backface-visibility: hidden;
36
  @include transition($carousel-transition);
Mark Otto's avatar
Mark Otto committed
37
}
38

Mark Otto's avatar
Mark Otto committed
39
40
41
.carousel-item.active,
.carousel-item-next,
.carousel-item-prev {
Mark Otto's avatar
Mark Otto committed
42
  display: block;
Mark Otto's avatar
Mark Otto committed
43
}
44

45
.carousel-item-next:not(.carousel-item-left),
Mark Otto's avatar
Mark Otto committed
46
.active.carousel-item-right {
47
  transform: translateX(100%);
Mark Otto's avatar
Mark Otto committed
48
}
Mark Otto's avatar
Mark Otto committed
49

50
.carousel-item-prev:not(.carousel-item-right),
Mark Otto's avatar
Mark Otto committed
51
.active.carousel-item-left {
52
  transform: translateX(-100%);
53
}
54

Mark Otto's avatar
Mark Otto committed
55

56
57
58
59
60
61
62
63
//
// Alternate transitions
//

.carousel-fade {
  .carousel-item {
    opacity: 0;
    transition-property: opacity;
64
    transform: none;
65
66
67
68
69
  }

  .carousel-item.active,
  .carousel-item-next.carousel-item-left,
  .carousel-item-prev.carousel-item-right {
70
    z-index: 1;
71
72
73
74
75
    opacity: 1;
  }

  .active.carousel-item-left,
  .active.carousel-item-right {
76
    z-index: 0;
77
    opacity: 0;
78
    @include transition(opacity 0s $carousel-transition-duration);
79
80
81
82
  }
}


Mark Otto's avatar
Mark Otto committed
83
//
84
// Left/right controls for nav
Mark Otto's avatar
Mark Otto committed
85
//
86

87
88
.carousel-control-prev,
.carousel-control-next {
89
  position: absolute;
Mark Otto's avatar
Mark Otto committed
90
91
  top: 0;
  bottom: 0;
92
  z-index: 1;
Mark Otto's avatar
Mark Otto committed
93
94
  // Use flex for alignment (1-3)
  display: flex; // 1. allow flex styles
Mark Otto's avatar
linting    
Mark Otto committed
95
96
  align-items: center; // 2. vertically center contents
  justify-content: center; // 3. horizontally center contents
Mark Otto's avatar
Mark Otto committed
97
98
  width: $carousel-control-width;
  color: $carousel-control-color;
99
  text-align: center;
100
  opacity: $carousel-control-opacity;
101
  @include transition($carousel-control-transition);
102

103
  // Hover/focus state
Mark Otto's avatar
Mark Otto committed
104
105
  &:hover,
  &:focus {
Mark Otto's avatar
Mark Otto committed
106
    color: $carousel-control-color;
107
    text-decoration: none;
108
    outline: 0;
109
    opacity: $carousel-control-hover-opacity;
110
  }
Mark Otto's avatar
Mark Otto committed
111
}
112
113
.carousel-control-prev {
  left: 0;
Mark Otto's avatar
Mark Otto committed
114
  @if $enable-gradients {
115
    background-image: linear-gradient(90deg, rgba($black, .25), rgba($black, .001));
Mark Otto's avatar
Mark Otto committed
116
  }
117
118
119
}
.carousel-control-next {
  right: 0;
Mark Otto's avatar
Mark Otto committed
120
  @if $enable-gradients {
121
    background-image: linear-gradient(270deg, rgba($black, .25), rgba($black, .001));
Mark Otto's avatar
Mark Otto committed
122
  }
123
}
Mark Otto's avatar
Mark Otto committed
124

125
126
127
// Icons for within
.carousel-control-prev-icon,
.carousel-control-next-icon {
Mark Otto's avatar
Mark Otto committed
128
  display: inline-block;
Mark Otto's avatar
Mark Otto committed
129
130
  width: $carousel-control-icon-width;
  height: $carousel-control-icon-width;
Martijn Cuppens's avatar
Martijn Cuppens committed
131
  background: no-repeat 50% / 100% 100%;
Mark Otto's avatar
Mark Otto committed
132
}
133
.carousel-control-prev-icon {
134
  background-image: escape-svg($carousel-control-prev-icon-bg);
Mark Otto's avatar
Mark Otto committed
135
}
136
.carousel-control-next-icon {
137
  background-image: escape-svg($carousel-control-next-icon-bg);
138
}
Mark Otto's avatar
Mark Otto committed
139

Mark Otto's avatar
Mark Otto committed
140

141
// Optional indicator pips
142
//
Quy's avatar
Quy committed
143
// Add an ordered list with the following class and add a list item for each
144
145
// slide your carousel holds.

146
147
.carousel-indicators {
  position: absolute;
148
  right: 0;
149
  bottom: 0;
150
  left: 0;
Martijn Cuppens's avatar
Martijn Cuppens committed
151
  z-index: 2;
Mark Otto's avatar
Mark Otto committed
152
153
  display: flex;
  justify-content: center;
Quy's avatar
Quy committed
154
  padding-left: 0; // override <ol> default
155
156
157
  // Use the .carousel-control's width as margin so we don't overlay those
  margin-right: $carousel-control-width;
  margin-left: $carousel-control-width;
158
  list-style: none;
159
160

  li {
161
    box-sizing: content-box;
Mark Otto's avatar
Mark Otto committed
162
    flex: 0 1 auto;
163
    width: $carousel-indicator-width;
Mark Otto's avatar
Mark Otto committed
164
    height: $carousel-indicator-height;
Mark Otto's avatar
Mark Otto committed
165
166
    margin-right: $carousel-indicator-spacer;
    margin-left: $carousel-indicator-spacer;
167
    text-indent: -999px;
168
    cursor: pointer;
169
    background-color: $carousel-indicator-active-bg;
170
171
172
173
    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;
174
175
    opacity: .5;
    @include transition($carousel-indicator-transition);
176
  }
177

178
  .active {
179
    opacity: 1;
180
181
  }
}
182

Mark Otto's avatar
Mark Otto committed
183

184
// Optional captions
Mark Otto's avatar
Mark Otto committed
185
//
Quy's avatar
Quy committed
186
//
Mark Otto's avatar
Mark Otto committed
187

188
189
.carousel-caption {
  position: absolute;
190
  right: (100% - $carousel-caption-width) / 2;
191
  bottom: 20px;
192
  left: (100% - $carousel-caption-width) / 2;
193
194
  padding-top: 20px;
  padding-bottom: 20px;
Mark Otto's avatar
Mark Otto committed
195
  color: $carousel-caption-color;
196
  text-align: center;
197
}