_carousel.scss 3.77 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
  width: $carousel-control-width;
  color: $carousel-control-color;
65
  text-align: center;
66
  opacity: $carousel-control-opacity;
67
  // We can't have a transition here because WebKit cancels the carousel
68
  // animation if you trip this while in the middle of another animation.
69

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

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

Mark Otto's avatar
Mark Otto committed
111

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

117
118
.carousel-indicators {
  position: absolute;
119
  right: 0;
120
  bottom: 10px;
121
  left: 0;
Mark Otto's avatar
Mark Otto committed
122
  z-index: 15;
123
124
125
126
  // Use the .carousel-control's width as margin so we don't overlay those
  margin-right: $carousel-control-width;
  margin-left: $carousel-control-width;
  padding-left: 0; // override <ul> default
Mark Otto's avatar
Mark Otto committed
127
  text-align: center;
128
  list-style: none;
129
130

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

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

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

Mark Otto's avatar
Mark Otto committed
165

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

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