carousel.less 5.8 KB

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