carousel.less 5.28 KB
Newer Older
1
2
3
4
//
// Carousel
// --------------------------------------------------

5

Mark Otto's avatar
Mark Otto committed
6
// Wrapper for the slide container and indicators
7
.carousel {
8
9
  position: relative;
}
10

11
.carousel-inner {
Mark Otto's avatar
Mark Otto committed
12
  position: relative;
13
14
  overflow: hidden;
  width: 100%;
15

16
  > .item {
17
18
19
20
    display: none;
    position: relative;
    .transition(.6s ease-in-out left);

21
22
    // Account for jankitude on images
    > img,
RJ Regenold's avatar
RJ Regenold committed
23
    > a > img {
24
      &:extend(.img-responsive);
25
26
      line-height: 1;
    }
27
28

    // WebKit CSS3 transforms for supported devices
29
    @media all and (transform-3d), (-webkit-transform-3d) {
30
31
      .transition-transform(~'0.6s ease-in-out');
      .backface-visibility(~'hidden');
32
      .perspective(1000px);
Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
33

Hayden Bleasel's avatar
Hayden Bleasel committed
34
35
      &.next,
      &.active.right {
36
        .translate3d(100%, 0, 0);
37
38
        left: 0;
      }
Hayden Bleasel's avatar
Hayden Bleasel committed
39
40
      &.prev,
      &.active.left {
41
        .translate3d(-100%, 0, 0);
42
43
        left: 0;
      }
Hayden Bleasel's avatar
Hayden Bleasel committed
44
45
46
      &.next.left,
      &.prev.right,
      &.active {
47
        .translate3d(0, 0, 0);
48
49
50
        left: 0;
      }
    }
51
52
  }

53
54
  > .active,
  > .next,
Nick Schonning's avatar
Nick Schonning committed
55
56
57
  > .prev {
    display: block;
  }
58

59
  > .active {
60
61
    left: 0;
  }
62

63
64
  > .next,
  > .prev {
65
66
67
68
69
    position: absolute;
    top: 0;
    width: 100%;
  }

70
  > .next {
71
72
    left: 100%;
  }
73
  > .prev {
74
75
    left: -100%;
  }
76
77
  > .next.left,
  > .prev.right {
78
79
80
    left: 0;
  }

81
  > .active.left {
82
83
    left: -100%;
  }
84
  > .active.right {
85
86
    left: 100%;
  }
87

88
}
89

90
91
92
93
94
// Left/right controls for nav
// ---------------------------

.carousel-control {
  position: absolute;
Mark Otto's avatar
Mark Otto committed
95
96
97
  top: 0;
  left: 0;
  bottom: 0;
syed's avatar
syed committed
98
99
100
  width: @carousel-control-width;
  .opacity(@carousel-control-opacity);
  font-size: @carousel-control-font-size;
101
  color: @carousel-control-color;
102
  text-align: center;
Mark Otto's avatar
Mark Otto committed
103
  text-shadow: @carousel-text-shadow;
Chris Rebert's avatar
Chris Rebert committed
104
  // We can't have this transition here because WebKit cancels the carousel
105
  // animation if you trip this while in the middle of another animation.
106

Mark Otto's avatar
Mark Otto committed
107
108
  // Set gradients for backgrounds
  &.left {
Mark Otto's avatar
Mark Otto committed
109
    #gradient > .horizontal(@start-color: rgba(0,0,0,.5); @end-color: rgba(0,0,0,.0001));
Mark Otto's avatar
Mark Otto committed
110
  }
111
112
  &.right {
    left: auto;
Mark Otto's avatar
Mark Otto committed
113
    right: 0;
Mark Otto's avatar
Mark Otto committed
114
    #gradient > .horizontal(@start-color: rgba(0,0,0,.0001); @end-color: rgba(0,0,0,.5));
115
116
  }

117
118
119
  // Hover/focus state
  &:hover,
  &:focus {
120
    outline: 0;
Mark Otto's avatar
Mark Otto committed
121
    color: @carousel-control-color;
122
    text-decoration: none;
123
    .opacity(.9);
124
  }
Mark Otto's avatar
Mark Otto committed
125
126

  // Toggles
Mark Otto's avatar
Mark Otto committed
127
  .icon-prev,
128
129
130
  .icon-next,
  .glyphicon-chevron-left,
  .glyphicon-chevron-right {
Mark Otto's avatar
Mark Otto committed
131
132
133
    position: absolute;
    top: 50%;
    z-index: 5;
Mark Otto's avatar
Mark Otto committed
134
    display: inline-block;
135
136
  }
  .icon-prev,
137
138
  .glyphicon-chevron-left {
    left: 50%;
139
    margin-left: -10px;
140
141
142
143
  }
  .icon-next,
  .glyphicon-chevron-right {
    right: 50%;
144
    margin-right: -10px;
145
146
  }
  .icon-prev,
147
  .icon-next {
Mark Otto's avatar
Mark Otto committed
148
149
150
    width:  20px;
    height: 20px;
    margin-top: -10px;
151
    line-height: 1;
fat's avatar
fat committed
152
    font-family: serif;
Mark Otto's avatar
Mark Otto committed
153
  }
154

155

156
157
  .icon-prev {
    &:before {
158
      content: '\2039';// SINGLE LEFT-POINTING ANGLE QUOTATION MARK (U+2039)
159
160
161
162
    }
  }
  .icon-next {
    &:before {
163
      content: '\203a';// SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (U+203A)
164
165
    }
  }
166
}
Mark Otto's avatar
Mark Otto committed
167

168
// Optional indicator pips
169
//
170
// Add an unordered list with the following class and add a list item for each
171
172
// slide your carousel holds.

173
174
.carousel-indicators {
  position: absolute;
175
  bottom: 10px;
Mark Otto's avatar
Mark Otto committed
176
  left: 50%;
Mark Otto's avatar
Mark Otto committed
177
  z-index: 15;
178
179
  width: 60%;
  margin-left: -30%;
180
  padding-left: 0;
181
  list-style: none;
Mark Otto's avatar
Mark Otto committed
182
  text-align: center;
183
184

  li {
Mark Otto's avatar
Mark Otto committed
185
    display: inline-block;
186
187
188
    width:  10px;
    height: 10px;
    margin: 1px;
189
    text-indent: -999px;
Mark Otto's avatar
Mark Otto committed
190
    border: 1px solid @carousel-indicator-border-color;
191
    border-radius: 10px;
192
    cursor: pointer;
193
194
195
196
197
198

    // IE8-9 hack for event handling
    //
    // Internet Explorer 8-9 does not support clicks on elements without a set
    // `background-color`. We cannot use `filter` since that's not viewed as a
    // background color by the browser. Thus, a hack is needed.
199
    // See https://developer.mozilla.org/en-US/docs/Web/Events/click#Internet_Explorer
200
201
202
203
204
    //
    // For IE8, we set solid black as it doesn't support `rgba()`. For IE9, we
    // set alpha transparency for the best results possible.
    background-color: #000 \9; // IE8
    background-color: rgba(0,0,0,0); // IE9
205
206
  }
  .active {
207
208
209
    margin: 0;
    width:  12px;
    height: 12px;
Mark Otto's avatar
Mark Otto committed
210
    background-color: @carousel-indicator-active-bg;
211
212
  }
}
213

214
215
216
217
218
// Optional captions
// -----------------------------
// Hidden by default for smaller viewports
.carousel-caption {
  position: absolute;
219
220
  left: 15%;
  right: 15%;
221
  bottom: 20px;
222
  z-index: 10;
223
224
  padding-top: 20px;
  padding-bottom: 20px;
225
  color: @carousel-caption-color;
226
  text-align: center;
Mark Otto's avatar
Mark Otto committed
227
  text-shadow: @carousel-text-shadow;
228
229
230
  & .btn {
    text-shadow: none; // No shadow for button elements in carousel-caption
  }
231
232
}

233

234
// Scale up controls for tablets and up
Zlatan Vasović's avatar
Zlatan Vasović committed
235
@media screen and (min-width: @screen-sm-min) {
nextgenthemes's avatar
nextgenthemes committed
236

237
  // Scale up the controls a smidge
238
  .carousel-control {
stoudenmire's avatar
stoudenmire committed
239
240
    .glyphicon-chevron-left,
    .glyphicon-chevron-right,
241
242
243
244
245
246
247
    .icon-prev,
    .icon-next {
      width: 30px;
      height: 30px;
      margin-top: -15px;
      font-size: 30px;
    }
248
249
250
251
252
253
254
255
    .glyphicon-chevron-left,
    .icon-prev {
      margin-left: -15px;
    }
    .glyphicon-chevron-right,
    .icon-next {
      margin-right: -15px;
    }
nextgenthemes's avatar
nextgenthemes committed
256
  }
Mark Otto's avatar
Mark Otto committed
257

258
259
  // Show and left align the captions
  .carousel-caption {
260
261
262
    left: 20%;
    right: 20%;
    padding-bottom: 30px;
263
  }
264
265
266
267
268

  // Move up the indicators
  .carousel-indicators {
    bottom: 20px;
  }
269
}