_carousel.scss 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // Wrapper for the slide container and indicators
  2. .carousel {
  3. position: relative;
  4. }
  5. .carousel-inner {
  6. position: relative;
  7. width: 100%;
  8. overflow: hidden;
  9. }
  10. .carousel-item {
  11. position: relative;
  12. display: none;
  13. align-items: center;
  14. width: 100%;
  15. @include transition($carousel-transition);
  16. backface-visibility: hidden;
  17. perspective: 1000px;
  18. }
  19. .carousel-item.active,
  20. .carousel-item-next,
  21. .carousel-item-prev {
  22. display: block;
  23. }
  24. .carousel-item-next,
  25. .carousel-item-prev {
  26. position: absolute;
  27. top: 0;
  28. }
  29. // CSS3 transforms when supported by the browser
  30. .carousel-item-next.carousel-item-left,
  31. .carousel-item-prev.carousel-item-right {
  32. transform: translateX(0);
  33. @supports (transform-style: preserve-3d) {
  34. transform: translate3d(0, 0, 0);
  35. }
  36. }
  37. .carousel-item-next,
  38. .active.carousel-item-right {
  39. transform: translateX(100%);
  40. @supports (transform-style: preserve-3d) {
  41. transform: translate3d(100%, 0, 0);
  42. }
  43. }
  44. .carousel-item-prev,
  45. .active.carousel-item-left {
  46. transform: translateX(-100%);
  47. @supports (transform-style: preserve-3d) {
  48. transform: translate3d(-100%, 0, 0);
  49. }
  50. }
  51. //
  52. // Left/right controls for nav
  53. //
  54. .carousel-control-prev,
  55. .carousel-control-next {
  56. position: absolute;
  57. top: 0;
  58. bottom: 0;
  59. // Use flex for alignment (1-3)
  60. display: flex; // 1. allow flex styles
  61. align-items: center; // 2. vertically center contents
  62. justify-content: center; // 3. horizontally center contents
  63. width: $carousel-control-width;
  64. 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. // Hover/focus state
  70. @include hover-focus {
  71. color: $carousel-control-color;
  72. text-decoration: none;
  73. outline: 0;
  74. opacity: .9;
  75. }
  76. }
  77. .carousel-control-prev {
  78. left: 0;
  79. @if $enable-gradients {
  80. background: linear-gradient(90deg, rgba(0,0,0,.25), rgba(0,0,0,.001));
  81. }
  82. }
  83. .carousel-control-next {
  84. right: 0;
  85. @if $enable-gradients {
  86. background: linear-gradient(270deg, rgba(0,0,0,.25), rgba(0,0,0,.001));
  87. }
  88. }
  89. // Icons for within
  90. .carousel-control-prev-icon,
  91. .carousel-control-next-icon {
  92. display: inline-block;
  93. width: $carousel-control-icon-width;
  94. height: $carousel-control-icon-width;
  95. background: transparent no-repeat center center;
  96. background-size: 100% 100%;
  97. }
  98. .carousel-control-prev-icon {
  99. background-image: $carousel-control-prev-icon-bg;
  100. }
  101. .carousel-control-next-icon {
  102. background-image: $carousel-control-next-icon-bg;
  103. }
  104. // Optional indicator pips
  105. //
  106. // Add an ordered list with the following class and add a list item for each
  107. // slide your carousel holds.
  108. .carousel-indicators {
  109. position: absolute;
  110. right: 0;
  111. bottom: 10px;
  112. left: 0;
  113. z-index: 15;
  114. display: flex;
  115. justify-content: center;
  116. padding-left: 0; // override <ol> default
  117. // Use the .carousel-control's width as margin so we don't overlay those
  118. margin-right: $carousel-control-width;
  119. margin-left: $carousel-control-width;
  120. list-style: none;
  121. li {
  122. position: relative;
  123. flex: 0 1 auto;
  124. width: $carousel-indicator-width;
  125. height: $carousel-indicator-height;
  126. margin-right: $carousel-indicator-spacer;
  127. margin-left: $carousel-indicator-spacer;
  128. text-indent: -999px;
  129. background-color: rgba($carousel-indicator-active-bg, .5);
  130. // Use pseudo classes to increase the hit area by 10px on top and bottom.
  131. &::before {
  132. position: absolute;
  133. top: -10px;
  134. left: 0;
  135. display: inline-block;
  136. width: 100%;
  137. height: 10px;
  138. content: "";
  139. }
  140. &::after {
  141. position: absolute;
  142. bottom: -10px;
  143. left: 0;
  144. display: inline-block;
  145. width: 100%;
  146. height: 10px;
  147. content: "";
  148. }
  149. }
  150. .active {
  151. background-color: $carousel-indicator-active-bg;
  152. }
  153. }
  154. // Optional captions
  155. //
  156. //
  157. .carousel-caption {
  158. position: absolute;
  159. right: ((100% - $carousel-caption-width) / 2);
  160. bottom: 20px;
  161. left: ((100% - $carousel-caption-width) / 2);
  162. z-index: 10;
  163. padding-top: 20px;
  164. padding-bottom: 20px;
  165. color: $carousel-caption-color;
  166. text-align: center;
  167. }