carousel.less 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. #gradient >
  72. .horizontal(
  73. @start-color: rgba(0, 0, 0, 0.5) ; @end-color: rgba(0, 0, 0, 0.0001)
  74. );
  75. }
  76. &.right {
  77. left: auto;
  78. right: 0;
  79. #gradient >
  80. .horizontal(
  81. @start-color: rgba(0, 0, 0, 0.0001) ; @end-color: rgba(0, 0, 0, 0.5)
  82. );
  83. }
  84. // Hover/focus state
  85. &:hover,
  86. &:focus {
  87. outline: none;
  88. color: @carousel-control-color;
  89. text-decoration: none;
  90. .opacity(0.9);
  91. }
  92. // Toggles
  93. .icon-prev,
  94. .icon-next,
  95. .glyphicon-chevron-left,
  96. .glyphicon-chevron-right {
  97. position: absolute;
  98. top: 50%;
  99. z-index: 5;
  100. display: inline-block;
  101. }
  102. .icon-prev,
  103. .glyphicon-chevron-left {
  104. left: 50%;
  105. }
  106. .icon-next,
  107. .glyphicon-chevron-right {
  108. right: 50%;
  109. }
  110. .icon-prev,
  111. .icon-next {
  112. width: 20px;
  113. height: 20px;
  114. margin-top: -10px;
  115. margin-left: -10px;
  116. font-family: serif;
  117. }
  118. .icon-prev {
  119. &:before {
  120. content: '\2039'; // SINGLE LEFT-POINTING ANGLE QUOTATION MARK (U+2039)
  121. }
  122. }
  123. .icon-next {
  124. &:before {
  125. content: '\203a'; // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (U+203A)
  126. }
  127. }
  128. }
  129. // Optional indicator pips
  130. //
  131. // Add an unordered list with the following class and add a list item for each
  132. // slide your carousel holds.
  133. .carousel-indicators {
  134. position: absolute;
  135. bottom: 10px;
  136. left: 50%;
  137. z-index: 15;
  138. width: 60%;
  139. margin-left: -30%;
  140. padding-left: 0;
  141. list-style: none;
  142. text-align: center;
  143. li {
  144. display: inline-block;
  145. width: 10px;
  146. height: 10px;
  147. margin: 1px;
  148. text-indent: -999px;
  149. border: 1px solid @carousel-indicator-border-color;
  150. border-radius: 10px;
  151. cursor: pointer;
  152. // IE8-9 hack for event handling
  153. //
  154. // Internet Explorer 8-9 does not support clicks on elements without a set
  155. // `background-color`. We cannot use `filter` since that's not viewed as a
  156. // background color by the browser. Thus, a hack is needed.
  157. //
  158. // For IE8, we set solid black as it doesn't support `rgba()`. For IE9, we
  159. // set alpha transparency for the best results possible.
  160. background-color: #000 \9; // IE8
  161. background-color: rgba(0, 0, 0, 0); // IE9
  162. }
  163. .active {
  164. margin: 0;
  165. width: 12px;
  166. height: 12px;
  167. background-color: @carousel-indicator-active-bg;
  168. }
  169. }
  170. // Optional captions
  171. // -----------------------------
  172. // Hidden by default for smaller viewports
  173. .carousel-caption {
  174. position: absolute;
  175. left: 15%;
  176. right: 15%;
  177. bottom: 20px;
  178. z-index: 10;
  179. padding-top: 20px;
  180. padding-bottom: 20px;
  181. color: @carousel-caption-color;
  182. text-align: center;
  183. text-shadow: @carousel-text-shadow;
  184. & .btn {
  185. text-shadow: none; // No shadow for button elements in carousel-caption
  186. }
  187. }
  188. // Scale up controls for tablets and up
  189. @media screen and (min-width: @screen-sm-min) {
  190. // Scale up the controls a smidge
  191. .carousel-control {
  192. .glyphicon-chevron-left,
  193. .glyphicon-chevron-right,
  194. .icon-prev,
  195. .icon-next {
  196. width: 30px;
  197. height: 30px;
  198. margin-top: -15px;
  199. margin-left: -15px;
  200. font-size: 30px;
  201. }
  202. }
  203. // Show and left align the captions
  204. .carousel-caption {
  205. left: 20%;
  206. right: 20%;
  207. padding-bottom: 30px;
  208. }
  209. // Move up the indicators
  210. .carousel-indicators {
  211. bottom: 20px;
  212. }
  213. }