_carousel.scss 3.67 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;
Mark Otto's avatar
Mark Otto committed
15
  width: 100%;
16

Mark Otto's avatar
Mark Otto committed
17
  @include if-supports-3d-transforms() {
18
    @include transition(transform .6s ease-in-out);
Mark Otto's avatar
Mark Otto committed
19
20
    backface-visibility: hidden;
    perspective: 1000px;
21
  }
Mark Otto's avatar
Mark Otto committed
22
}
23

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

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

Mark Otto's avatar
Mark Otto committed
36
37
38
39
40
41
// CSS3 transforms when supported by the browser
@include if-supports-3d-transforms() {
  .carousel-item-next.carousel-item-left,
  .carousel-item-prev.carousel-item-right {
    transform: translate3d(0, 0, 0);
  }
42

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

  .carousel-item-prev,
  .active.carousel-item-left {
    transform: translate3d(-100%, 0, 0);
  }
52
}
53

Mark Otto's avatar
Mark Otto committed
54
55

//
56
// Left/right controls for nav
Mark Otto's avatar
Mark Otto committed
57
//
58
59
60

.carousel-control {
  position: absolute;
Mark Otto's avatar
Mark Otto committed
61
62
  top: 0;
  bottom: 0;
Mark Otto's avatar
Mark Otto committed
63
64
65
  width: $carousel-control-width;
  font-size: $carousel-control-font-size;
  color: $carousel-control-color;
66
  text-align: center;
67
  opacity: $carousel-control-opacity;
68
  // We can't have a transition here because WebKit cancels the carousel
69
  // animation if you trip this while in the middle of another animation.
70

71
  // Hover/focus state
72
  @include hover-focus {
Mark Otto's avatar
Mark Otto committed
73
    color: $carousel-control-color;
74
    text-decoration: none;
75
    outline: 0;
76
    opacity: .9;
77
  }
Mark Otto's avatar
Mark Otto committed
78
}
79
80
81
82
83
84
.carousel-control-prev {
  left: 0;
}
.carousel-control-next {
  right: 0;
}
Mark Otto's avatar
Mark Otto committed
85

86
87
88
// Icons for within
.carousel-control-prev-icon,
.carousel-control-next-icon {
Mark Otto's avatar
Mark Otto committed
89
90
91
92
93
94
95
96
97
  position: absolute;
  top: 50%;
  z-index: 5;
  display: inline-block;
  width: $carousel-icon-width;
  height: $carousel-icon-width;
  margin-top: -($carousel-icon-width / 2);
  font-family: serif;
  line-height: 1;
98
99
  background: transparent no-repeat center center;
  background-size: 100% 100%;
Mark Otto's avatar
Mark Otto committed
100
}
101
.carousel-control-prev-icon {
Mark Otto's avatar
Mark Otto committed
102
103
  left: 50%;
  margin-left: -($carousel-icon-width / 2);
104
  background-image: $carousel-control-prev-icon-bg;
Mark Otto's avatar
Mark Otto committed
105
}
106
.carousel-control-next-icon {
Mark Otto's avatar
Mark Otto committed
107
108
  right: 50%;
  margin-right: -($carousel-icon-width / 2);
109
  background-image: $carousel-control-next-icon-bg;
110
}
Mark Otto's avatar
Mark Otto committed
111

Mark Otto's avatar
Mark Otto committed
112

113
// Optional indicator pips
114
//
115
// Add an unordered list with the following class and add a list item for each
116
117
// slide your carousel holds.

118
119
.carousel-indicators {
  position: absolute;
120
  bottom: 10px;
Mark Otto's avatar
Mark Otto committed
121
  left: 50%;
Mark Otto's avatar
Mark Otto committed
122
  z-index: 15;
123
  width: $carousel-indicators-width;
124
  padding-left: 0;
125
  margin-left: -($carousel-indicators-width / 2);
Mark Otto's avatar
Mark Otto committed
126
  text-align: center;
127
  list-style: none;
128
129

  li {
Mark Otto's avatar
Mark Otto committed
130
    position: relative;
Mark Otto's avatar
Mark Otto committed
131
    display: inline-block;
Mark Otto's avatar
Mark Otto committed
132
133
    width: $carousel-indicator-width;
    height: $carousel-indicator-height;
134
    text-indent: -999px;
135
    cursor: pointer;
Mark Otto's avatar
Mark Otto committed
136
137
    background-color: rgba($carousel-indicator-active-bg, .5);

Mark Otto's avatar
Mark Otto committed
138
    // Use pseudo classes to increase the hit area by 10px on top and bottom.
Mark Otto's avatar
Mark Otto committed
139
140
141
142
143
144
145
    &::before {
      position: absolute;
      top: -10px;
      left: 0;
      display: inline-block;
      width: 100%;
      height: 10px;
Mark Otto's avatar
linting    
Mark Otto committed
146
      content: "";
Mark Otto's avatar
Mark Otto committed
147
148
149
150
151
152
153
154
    }
    &::after {
      position: absolute;
      bottom: -10px;
      left: 0;
      display: inline-block;
      width: 100%;
      height: 10px;
Mark Otto's avatar
linting    
Mark Otto committed
155
      content: "";
Mark Otto's avatar
Mark Otto committed
156
    }
157
  }
158

159
  .active {
Mark Otto's avatar
Mark Otto committed
160
    background-color: $carousel-indicator-active-bg;
161
162
  }
}
163

Mark Otto's avatar
Mark Otto committed
164

165
// Optional captions
Mark Otto's avatar
Mark Otto committed
166
167
168
//
// Hidden by default for smaller viewports.

169
170
.carousel-caption {
  position: absolute;
171
  right: ((100% - $carousel-caption-width) / 2);
172
  bottom: 20px;
173
  left: ((100% - $carousel-caption-width) / 2);
174
  z-index: 10;
175
176
  padding-top: 20px;
  padding-bottom: 20px;
Mark Otto's avatar
Mark Otto committed
177
  color: $carousel-caption-color;
178
  text-align: center;
179
}