carousel.less 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. //
  2. // Carousel
  3. // --------------------------------------------------
  4. // Wrapper for the slide container and indicators
  5. .carousel {
  6. position: relative;
  7. }
  8. .carousel-inner {
  9. position: relative;
  10. overflow: hidden;
  11. width: 100%;
  12. > .item {
  13. display: none;
  14. position: relative;
  15. .transition(0.6s ease-in-out left);
  16. // Account for jankitude on images
  17. > img,
  18. > a > img {
  19. &:extend(.img-responsive);
  20. line-height: 1;
  21. }
  22. }
  23. > .active,
  24. > .next,
  25. > .prev {
  26. display: block;
  27. }
  28. > .active {
  29. left: 0;
  30. }
  31. > .next,
  32. > .prev {
  33. position: absolute;
  34. top: 0;
  35. width: 100%;
  36. }
  37. > .next {
  38. left: 100%;
  39. }
  40. > .prev {
  41. left: -100%;
  42. }
  43. > .next.left,
  44. > .prev.right {
  45. left: 0;
  46. }
  47. > .active.left {
  48. left: -100%;
  49. }
  50. > .active.right {
  51. left: 100%;
  52. }
  53. }
  54. // Left/right controls for nav
  55. // ---------------------------
  56. .carousel-control {
  57. position: absolute;
  58. top: 0;
  59. left: 0;
  60. bottom: 0;
  61. width: @carousel-control-width;
  62. .opacity(@carousel-control-opacity);
  63. font-size: @carousel-control-font-size;
  64. color: @carousel-control-color;
  65. text-align: center;
  66. text-shadow: @carousel-text-shadow;
  67. // We can't have this transition here because WebKit cancels the carousel
  68. // animation if you trip this while in the middle of another animation.
  69. // Set gradients for backgrounds
  70. &.left {
  71. // prettier-ignore
  72. #gradient >
  73. .horizontal(
  74. @start-color: rgba(0, 0, 0, 0.5) ; @end-color: rgba(0, 0, 0, 0.0001)
  75. );
  76. }
  77. &.right {
  78. left: auto;
  79. right: 0;
  80. // prettier-ignore
  81. #gradient >
  82. .horizontal(
  83. @start-color: rgba(0, 0, 0, 0.0001) ; @end-color: rgba(0, 0, 0, 0.5)
  84. );
  85. }
  86. // Hover/focus state
  87. &:hover,
  88. &:focus {
  89. outline: none;
  90. color: @carousel-control-color;
  91. text-decoration: none;
  92. .opacity(0.9);
  93. }
  94. // Toggles
  95. .icon-prev,
  96. .icon-next,
  97. .glyphicon-chevron-left,
  98. .glyphicon-chevron-right {
  99. position: absolute;
  100. top: 50%;
  101. z-index: 5;
  102. display: inline-block;
  103. }
  104. .icon-prev,
  105. .glyphicon-chevron-left {
  106. left: 50%;
  107. }
  108. .icon-next,
  109. .glyphicon-chevron-right {
  110. right: 50%;
  111. }
  112. .icon-prev,
  113. .icon-next {
  114. width: 20px;
  115. height: 20px;
  116. margin-top: -10px;
  117. margin-left: -10px;
  118. font-family: serif;
  119. }
  120. .icon-prev {
  121. &:before {
  122. content: '\2039'; // SINGLE LEFT-POINTING ANGLE QUOTATION MARK (U+2039)
  123. }
  124. }
  125. .icon-next {
  126. &:before {
  127. content: '\203a'; // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (U+203A)
  128. }
  129. }
  130. }
  131. // Optional indicator pips
  132. //
  133. // Add an unordered list with the following class and add a list item for each
  134. // slide your carousel holds.
  135. .carousel-indicators {
  136. position: absolute;
  137. bottom: 10px;
  138. left: 50%;
  139. z-index: 15;
  140. width: 60%;
  141. margin-left: -30%;
  142. padding-left: 0;
  143. list-style: none;
  144. text-align: center;
  145. li {
  146. display: inline-block;
  147. width: 10px;
  148. height: 10px;
  149. margin: 1px;
  150. text-indent: -999px;
  151. border: 1px solid @carousel-indicator-border-color;
  152. border-radius: 10px;
  153. cursor: pointer;
  154. // IE8-9 hack for event handling
  155. //
  156. // Internet Explorer 8-9 does not support clicks on elements without a set
  157. // `background-color`. We cannot use `filter` since that's not viewed as a
  158. // background color by the browser. Thus, a hack is needed.
  159. //
  160. // For IE8, we set solid black as it doesn't support `rgba()`. For IE9, we
  161. // set alpha transparency for the best results possible.
  162. background-color: #000 \9; // IE8
  163. background-color: rgba(0, 0, 0, 0); // IE9
  164. }
  165. .active {
  166. margin: 0;
  167. width: 12px;
  168. height: 12px;
  169. background-color: @carousel-indicator-active-bg;
  170. }
  171. }
  172. // Optional captions
  173. // -----------------------------
  174. // Hidden by default for smaller viewports
  175. .carousel-caption {
  176. position: absolute;
  177. left: 15%;
  178. right: 15%;
  179. bottom: 20px;
  180. z-index: 10;
  181. padding-top: 20px;
  182. padding-bottom: 20px;
  183. color: @carousel-caption-color;
  184. text-align: center;
  185. text-shadow: @carousel-text-shadow;
  186. & .btn {
  187. text-shadow: none; // No shadow for button elements in carousel-caption
  188. }
  189. }
  190. // Scale up controls for tablets and up
  191. @media screen and (min-width: @screen-sm-min) {
  192. // Scale up the controls a smidge
  193. .carousel-control {
  194. .glyphicon-chevron-left,
  195. .glyphicon-chevron-right,
  196. .icon-prev,
  197. .icon-next {
  198. width: 30px;
  199. height: 30px;
  200. margin-top: -15px;
  201. margin-left: -15px;
  202. font-size: 30px;
  203. }
  204. }
  205. // Show and left align the captions
  206. .carousel-caption {
  207. left: 20%;
  208. right: 20%;
  209. padding-bottom: 30px;
  210. }
  211. // Move up the indicators
  212. .carousel-indicators {
  213. bottom: 20px;
  214. }
  215. }