_carousel.scss 4.11 KB
Newer Older
Mark Otto's avatar
Mark Otto committed
1
// Wrapper for the slide container and indicators
2
.carousel {
3
4
  position: relative;
}
5

6
.carousel-inner {
Mark Otto's avatar
Mark Otto committed
7
  position: relative;
8
  width: 100%;
9
  overflow: hidden;
Mark Otto's avatar
Mark Otto committed
10
}
11

Mark Otto's avatar
Mark Otto committed
12
13
14
.carousel-item {
  position: relative;
  display: none;
15
  align-items: center;
Mark Otto's avatar
Mark Otto committed
16
  width: 100%;
Mark Otto's avatar
Mark Otto committed
17
18
19
  @include transition($carousel-transition);
  backface-visibility: hidden;
  perspective: 1000px;
Mark Otto's avatar
Mark Otto committed
20
}
21

Mark Otto's avatar
Mark Otto committed
22
23
24
.carousel-item.active,
.carousel-item-next,
.carousel-item-prev {
Mark Otto's avatar
Mark Otto committed
25
  display: block;
Mark Otto's avatar
Mark Otto committed
26
}
27

Mark Otto's avatar
Mark Otto committed
28
29
.carousel-item-next,
.carousel-item-prev {
Mark Otto's avatar
Mark Otto committed
30
31
32
  position: absolute;
  top: 0;
}
33

Mark Otto's avatar
Mark Otto committed
34
// CSS3 transforms when supported by the browser
Mark Otto's avatar
Mark Otto committed
35
36
.carousel-item-next.carousel-item-left,
.carousel-item-prev.carousel-item-right {
37
38
39
40
41
  transform: translateX(0);

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

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

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

Mark Otto's avatar
Mark Otto committed
53
54
.carousel-item-prev,
.active.carousel-item-left {
55
56
57
58
59
  transform: translateX(-100%);

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

Mark Otto's avatar
Mark Otto committed
62
63

//
64
// Left/right controls for nav
Mark Otto's avatar
Mark Otto committed
65
//
66

67
68
.carousel-control-prev,
.carousel-control-next {
69
  position: absolute;
Mark Otto's avatar
Mark Otto committed
70
71
  top: 0;
  bottom: 0;
Mark Otto's avatar
Mark Otto committed
72
73
  // Use flex for alignment (1-3)
  display: flex; // 1. allow flex styles
Mark Otto's avatar
linting    
Mark Otto committed
74
75
  align-items: center; // 2. vertically center contents
  justify-content: center; // 3. horizontally center contents
Mark Otto's avatar
Mark Otto committed
76
77
  width: $carousel-control-width;
  color: $carousel-control-color;
78
  text-align: center;
79
  opacity: $carousel-control-opacity;
80
  // We can't have a transition here because WebKit cancels the carousel
81
  // animation if you trip this while in the middle of another animation.
82

83
  // Hover/focus state
84
  @include hover-focus {
Mark Otto's avatar
Mark Otto committed
85
    color: $carousel-control-color;
86
    text-decoration: none;
87
    outline: 0;
88
    opacity: .9;
89
  }
Mark Otto's avatar
Mark Otto committed
90
}
91
92
.carousel-control-prev {
  left: 0;
Mark Otto's avatar
Mark Otto committed
93
94
95
  @if $enable-gradients {
    background: linear-gradient(90deg, rgba(0,0,0,.25), rgba(0,0,0,.001));
  }
96
97
98
}
.carousel-control-next {
  right: 0;
Mark Otto's avatar
Mark Otto committed
99
100
101
  @if $enable-gradients {
    background: linear-gradient(270deg, rgba(0,0,0,.25), rgba(0,0,0,.001));
  }
102
}
Mark Otto's avatar
Mark Otto committed
103

104
105
106
// Icons for within
.carousel-control-prev-icon,
.carousel-control-next-icon {
Mark Otto's avatar
Mark Otto committed
107
  display: inline-block;
Mark Otto's avatar
Mark Otto committed
108
109
  width: $carousel-control-icon-width;
  height: $carousel-control-icon-width;
110
111
  background: transparent no-repeat center center;
  background-size: 100% 100%;
Mark Otto's avatar
Mark Otto committed
112
}
113
114
.carousel-control-prev-icon {
  background-image: $carousel-control-prev-icon-bg;
Mark Otto's avatar
Mark Otto committed
115
}
116
117
.carousel-control-next-icon {
  background-image: $carousel-control-next-icon-bg;
118
}
Mark Otto's avatar
Mark Otto committed
119

Mark Otto's avatar
Mark Otto committed
120

121
// Optional indicator pips
122
//
Quy's avatar
Quy committed
123
// Add an ordered list with the following class and add a list item for each
124
125
// slide your carousel holds.

126
127
.carousel-indicators {
  position: absolute;
128
  right: 0;
129
  bottom: 10px;
130
  left: 0;
Mark Otto's avatar
Mark Otto committed
131
  z-index: 15;
Mark Otto's avatar
Mark Otto committed
132
133
  display: flex;
  justify-content: center;
Quy's avatar
Quy committed
134
  padding-left: 0; // override <ol> default
135
136
137
  // Use the .carousel-control's width as margin so we don't overlay those
  margin-right: $carousel-control-width;
  margin-left: $carousel-control-width;
138
  list-style: none;
139
140

  li {
Mark Otto's avatar
Mark Otto committed
141
    position: relative;
Mark Otto's avatar
Mark Otto committed
142
    flex: 0 1 auto;
143
    width: $carousel-indicator-width;
Mark Otto's avatar
Mark Otto committed
144
    height: $carousel-indicator-height;
Mark Otto's avatar
Mark Otto committed
145
146
    margin-right: $carousel-indicator-spacer;
    margin-left: $carousel-indicator-spacer;
147
    text-indent: -999px;
Mark Otto's avatar
Mark Otto committed
148
149
    background-color: rgba($carousel-indicator-active-bg, .5);

Mark Otto's avatar
Mark Otto committed
150
    // Use pseudo classes to increase the hit area by 10px on top and bottom.
Mark Otto's avatar
Mark Otto committed
151
152
153
154
155
156
157
    &::before {
      position: absolute;
      top: -10px;
      left: 0;
      display: inline-block;
      width: 100%;
      height: 10px;
Mark Otto's avatar
linting    
Mark Otto committed
158
      content: "";
Mark Otto's avatar
Mark Otto committed
159
160
161
162
163
164
165
166
    }
    &::after {
      position: absolute;
      bottom: -10px;
      left: 0;
      display: inline-block;
      width: 100%;
      height: 10px;
Mark Otto's avatar
linting    
Mark Otto committed
167
      content: "";
Mark Otto's avatar
Mark Otto committed
168
    }
169
  }
170

171
  .active {
Mark Otto's avatar
Mark Otto committed
172
    background-color: $carousel-indicator-active-bg;
173
174
  }
}
175

Mark Otto's avatar
Mark Otto committed
176

177
// Optional captions
Mark Otto's avatar
Mark Otto committed
178
//
Quy's avatar
Quy committed
179
//
Mark Otto's avatar
Mark Otto committed
180

181
182
.carousel-caption {
  position: absolute;
183
  right: ((100% - $carousel-caption-width) / 2);
184
  bottom: 20px;
185
  left: ((100% - $carousel-caption-width) / 2);
186
  z-index: 10;
187
188
  padding-top: 20px;
  padding-bottom: 20px;
Mark Otto's avatar
Mark Otto committed
189
  color: $carousel-caption-color;
190
  text-align: center;
191
}