_carousel.scss 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. color: $carousel-control-color;
  84. text-align: center;
  85. opacity: $carousel-control-opacity;
  86. @include transition($carousel-control-transition);
  87. // Hover/focus state
  88. @include hover-focus() {
  89. color: $carousel-control-color;
  90. text-decoration: none;
  91. outline: 0;
  92. opacity: $carousel-control-hover-opacity;
  93. }
  94. }
  95. .carousel-control-prev {
  96. left: 0;
  97. @if $enable-gradients {
  98. background-image: linear-gradient(90deg, rgba($black, .25), rgba($black, .001));
  99. }
  100. }
  101. .carousel-control-next {
  102. right: 0;
  103. @if $enable-gradients {
  104. background-image: linear-gradient(270deg, rgba($black, .25), rgba($black, .001));
  105. }
  106. }
  107. // Icons for within
  108. .carousel-control-prev-icon,
  109. .carousel-control-next-icon {
  110. display: inline-block;
  111. width: $carousel-control-icon-width;
  112. height: $carousel-control-icon-width;
  113. background: 50% / 100% 100% no-repeat;
  114. }
  115. .carousel-control-prev-icon {
  116. background-image: escape-svg($carousel-control-prev-icon-bg);
  117. }
  118. .carousel-control-next-icon {
  119. background-image: escape-svg($carousel-control-next-icon-bg);
  120. }
  121. // Optional indicator pips
  122. //
  123. // Add an ordered list with the following class and add a list item for each
  124. // slide your carousel holds.
  125. .carousel-indicators {
  126. position: absolute;
  127. right: 0;
  128. bottom: 0;
  129. left: 0;
  130. z-index: 15;
  131. display: flex;
  132. justify-content: center;
  133. padding-left: 0; // override <ol> default
  134. // Use the .carousel-control's width as margin so we don't overlay those
  135. margin-right: $carousel-control-width;
  136. margin-left: $carousel-control-width;
  137. list-style: none;
  138. li {
  139. box-sizing: content-box;
  140. flex: 0 1 auto;
  141. width: $carousel-indicator-width;
  142. height: $carousel-indicator-height;
  143. margin-right: $carousel-indicator-spacer;
  144. margin-left: $carousel-indicator-spacer;
  145. text-indent: -999px;
  146. cursor: pointer;
  147. background-color: $carousel-indicator-active-bg;
  148. background-clip: padding-box;
  149. // Use transparent borders to increase the hit area by 10px on top and bottom.
  150. border-top: $carousel-indicator-hit-area-height solid transparent;
  151. border-bottom: $carousel-indicator-hit-area-height solid transparent;
  152. opacity: .5;
  153. @include transition($carousel-indicator-transition);
  154. }
  155. .active {
  156. opacity: 1;
  157. }
  158. }
  159. // Optional captions
  160. //
  161. //
  162. .carousel-caption {
  163. position: absolute;
  164. right: (100% - $carousel-caption-width) / 2;
  165. bottom: 20px;
  166. left: (100% - $carousel-caption-width) / 2;
  167. z-index: 10;
  168. padding-top: 20px;
  169. padding-bottom: 20px;
  170. color: $carousel-caption-color;
  171. text-align: center;
  172. }