_carousel.scss 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // Notes on the classes:
  2. //
  3. // 1. .carousel.pointer-event should ideally be pan-y (to allow for users to scroll vertically)
  4. // even when their scroll action started on a carousel, but for compatibility (with Firefox)
  5. // we're preventing all actions instead
  6. // 2. The .carousel-item-left and .carousel-item-right is used to indicate where
  7. // the active slide is heading.
  8. // 3. .active.carousel-item is the current slide.
  9. // 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.
  11. // 5. .carousel-item-next.carousel-item-left and .carousel-item-prev.carousel-item-right
  12. // is the upcoming slide in transition.
  13. .carousel {
  14. position: relative;
  15. }
  16. .carousel.pointer-event {
  17. touch-action: pan-y;
  18. }
  19. .carousel-inner {
  20. position: relative;
  21. width: 100%;
  22. overflow: hidden;
  23. @include clearfix();
  24. }
  25. .carousel-item {
  26. position: relative;
  27. display: none;
  28. float: left;
  29. width: 100%;
  30. margin-right: -100%;
  31. backface-visibility: hidden;
  32. @include transition($carousel-transition);
  33. }
  34. .carousel-item.active,
  35. .carousel-item-next,
  36. .carousel-item-prev {
  37. display: block;
  38. }
  39. .carousel-item-next:not(.carousel-item-left),
  40. .active.carousel-item-right {
  41. transform: translateX(100%);
  42. }
  43. .carousel-item-prev:not(.carousel-item-right),
  44. .active.carousel-item-left {
  45. transform: translateX(-100%);
  46. }
  47. //
  48. // Alternate transitions
  49. //
  50. .carousel-fade {
  51. .carousel-item {
  52. opacity: 0;
  53. transition-property: opacity;
  54. transform: none;
  55. }
  56. .carousel-item.active,
  57. .carousel-item-next.carousel-item-left,
  58. .carousel-item-prev.carousel-item-right {
  59. z-index: 1;
  60. opacity: 1;
  61. }
  62. .active.carousel-item-left,
  63. .active.carousel-item-right {
  64. z-index: 0;
  65. opacity: 0;
  66. @include transition(opacity 0s $carousel-transition-duration);
  67. }
  68. }
  69. //
  70. // Left/right controls for nav
  71. //
  72. .carousel-control-prev,
  73. .carousel-control-next {
  74. position: absolute;
  75. top: 0;
  76. bottom: 0;
  77. z-index: 1;
  78. // Use flex for alignment (1-3)
  79. display: flex; // 1. allow flex styles
  80. align-items: center; // 2. vertically center contents
  81. justify-content: center; // 3. horizontally center contents
  82. width: $carousel-control-width;
  83. padding: 0;
  84. color: $carousel-control-color;
  85. text-align: center;
  86. background: none;
  87. border: 0;
  88. opacity: $carousel-control-opacity;
  89. @include transition($carousel-control-transition);
  90. // Hover/focus state
  91. @include hover-focus() {
  92. color: $carousel-control-color;
  93. text-decoration: none;
  94. outline: 0;
  95. opacity: $carousel-control-hover-opacity;
  96. }
  97. }
  98. .carousel-control-prev {
  99. left: 0;
  100. @if $enable-gradients {
  101. background-image: linear-gradient(90deg, rgba($black, .25), rgba($black, .001));
  102. }
  103. }
  104. .carousel-control-next {
  105. right: 0;
  106. @if $enable-gradients {
  107. background-image: linear-gradient(270deg, rgba($black, .25), rgba($black, .001));
  108. }
  109. }
  110. // Icons for within
  111. .carousel-control-prev-icon,
  112. .carousel-control-next-icon {
  113. display: inline-block;
  114. width: $carousel-control-icon-width;
  115. height: $carousel-control-icon-width;
  116. background: 50% / 100% 100% no-repeat;
  117. }
  118. .carousel-control-prev-icon {
  119. background-image: escape-svg($carousel-control-prev-icon-bg);
  120. }
  121. .carousel-control-next-icon {
  122. background-image: escape-svg($carousel-control-next-icon-bg);
  123. }
  124. // Optional indicator pips
  125. //
  126. // Add an ordered list with the following class and add a list item for each
  127. // slide your carousel holds.
  128. .carousel-indicators {
  129. position: absolute;
  130. right: 0;
  131. bottom: 0;
  132. left: 0;
  133. z-index: 15;
  134. display: flex;
  135. justify-content: center;
  136. padding-left: 0; // override <ol> default
  137. // Use the .carousel-control's width as margin so we don't overlay those
  138. margin-right: $carousel-control-width;
  139. margin-left: $carousel-control-width;
  140. list-style: none;
  141. li {
  142. box-sizing: content-box;
  143. flex: 0 1 auto;
  144. width: $carousel-indicator-width;
  145. height: $carousel-indicator-height;
  146. margin-right: $carousel-indicator-spacer;
  147. margin-left: $carousel-indicator-spacer;
  148. text-indent: -999px;
  149. cursor: pointer;
  150. background-color: $carousel-indicator-active-bg;
  151. background-clip: padding-box;
  152. // Use transparent borders to increase the hit area by 10px on top and bottom.
  153. border-top: $carousel-indicator-hit-area-height solid transparent;
  154. border-bottom: $carousel-indicator-hit-area-height solid transparent;
  155. opacity: .5;
  156. @include transition($carousel-indicator-transition);
  157. }
  158. .active {
  159. opacity: 1;
  160. }
  161. }
  162. // Optional captions
  163. //
  164. //
  165. .carousel-caption {
  166. position: absolute;
  167. right: (100% - $carousel-caption-width) * .5;
  168. bottom: 20px;
  169. left: (100% - $carousel-caption-width) * .5;
  170. z-index: 10;
  171. padding-top: 20px;
  172. padding-bottom: 20px;
  173. color: $carousel-caption-color;
  174. text-align: center;
  175. }