slider.css 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /* mask the overflowing content, this will prevent scrollbars (optional) */
  2. .css-slider-mask {
  3. display: block;
  4. overflow: hidden;
  5. width: 100%;
  6. height: 100%;
  7. height:60vh;
  8. }
  9. /* base style for the slider, you can place or size as you like (optional) */
  10. .css-slider {
  11. list-style: none;
  12. margin: 0;
  13. padding: 0;
  14. display: none;
  15. height: 100%;
  16. z-index: 1;
  17. }
  18. /* inital trick to hide the slider from everyone */
  19. .css-slider {
  20. position: relative;
  21. display: none;
  22. }
  23. /* ... then a simple hack to only show for browsers that support :nth-child */
  24. body:nth-child(2) .css-slider {
  25. display: block;
  26. }
  27. /* style the slides */
  28. .css-slider .slide {
  29. display: block;
  30. position: absolute;
  31. left: 20px;
  32. top: 0;
  33. right: 0;
  34. bottom: 0;
  35. padding-left: 0;
  36. padding-right: 20px;
  37. z-index: 100;
  38. outline: 0; /* kill the focus rect! */
  39. }
  40. /* style the forward arrow */
  41. .css-slider .slide {
  42. background: url('/static/arrow-right.svg') no-repeat right center;
  43. background-size: 25px auto;
  44. }
  45. /* style the forward arrow hover state */
  46. .css-slider .slide:hover {
  47. background-image: url('/static/arrow-right-hover.svg');
  48. cursor: pointer;
  49. }
  50. /* reveal the focused slide, including last child for when there is no focus */
  51. .css-slider .slide:target,
  52. .css-slider .slide:target:hover,
  53. .css-slider .slide:focus,
  54. .css-slider .slide:focus:hover,
  55. .css-slider .slide:last-child,
  56. .css-slider .slide:last-child:hover {
  57. left: 40px;
  58. right: 40px;
  59. padding-left: 0;
  60. padding-right: 0;
  61. background: transparent;
  62. z-index: 101;
  63. cursor: default;
  64. }
  65. /* affect slides that have been navigated past the current */
  66. .css-slider .slide:target ~ .slide,
  67. .css-slider .slide:focus ~ .slide {
  68. padding-left: 40px;
  69. padding-right: 0;
  70. left: 0;
  71. right: 40px;
  72. }
  73. /* style the previous arrow */
  74. .css-slider .slide:target ~ .slide,
  75. .css-slider .slide:focus ~ .slide {
  76. background: url('/static/arrow-left.svg') no-repeat left center;
  77. background-size: 25px auto;
  78. }
  79. /* style the previous arrow hover state */
  80. .css-slider .slide:target ~ .slide:hover,
  81. .css-slider .slide:focus ~ .slide:hover {
  82. background-image: url('/static/arrow-left-hover.svg');
  83. }
  84. /* by default hide all slide contents, if animation is removed
  85. this is required to snap slides on or off */
  86. .css-slider .slide .slide-outer {
  87. display: none;
  88. width: 100%;
  89. height: 100%;
  90. }
  91. /* slide-inner is purely used for centering of the slide,
  92. using the table vertical center method. */
  93. .css-slider .slide .slide-outer .slide-inner {
  94. display: table-cell;
  95. vertical-align: middle;
  96. text-align: center;
  97. width: 100%;
  98. height: 100%;
  99. }
  100. /* a wrapper that holds whatever you wish to put in your slide,
  101. needs inline-block to center properly */
  102. .css-slider .slide .slide-outer .slide-inner .slide-gfx {
  103. position: relative;
  104. display: inline-block;
  105. }
  106. /* for the focused or last child, show the slide contents */
  107. .css-slider .slide:target .slide-outer,
  108. .css-slider .slide:focus .slide-outer,
  109. .css-slider .slide:last-child .slide-outer {
  110. display: block; /* if they don't support display table */
  111. display: table;
  112. }
  113. /* override the last-child slide if a slide has been focused */
  114. .css-slider .slide:target ~ .slide:last-child,
  115. .css-slider .slide:focus ~ .slide:last-child {
  116. cursor: pointer;
  117. }
  118. /* override the last-child slide contents if a slide has been focused */
  119. .css-slider .slide:target ~ .slide:last-child .slide-outer,
  120. .css-slider .slide:focus ~ .slide:last-child .slide-outer {
  121. display: none;
  122. }
  123. /* make sure the slide graphics appear above everything else */
  124. .css-slider .slide .slide-outer .slide-gfx {
  125. z-index: 102;
  126. text-align: left; /* override the centering back to defaults */
  127. }
  128. /* annoyingly the only "required" arbitrary part of the css --
  129. the following means the back arrow is supported for
  130. up to 20 slides. If you need more, just extend.
  131. This could be fixed if there was a selector like "~"
  132. or "+" which would work backwards through siblings.
  133. */
  134. .css-slider .slide:target ~ .slide:nth-child(1),
  135. .css-slider .slide:focus ~ .slide:nth-child(1) { z-index:99; }
  136. .css-slider .slide:target ~ .slide:nth-child(2),
  137. .css-slider .slide:focus ~ .slide:nth-child(2) { z-index:98; }
  138. .css-slider .slide:target ~ .slide:nth-child(3),
  139. .css-slider .slide:focus ~ .slide:nth-child(3) { z-index:97; }
  140. .css-slider .slide:target ~ .slide:nth-child(4),
  141. .css-slider .slide:focus ~ .slide:nth-child(4) { z-index:96; }
  142. .css-slider .slide:target ~ .slide:nth-child(5),
  143. .css-slider .slide:focus ~ .slide:nth-child(5) { z-index:95; }
  144. .css-slider .slide:target ~ .slide:nth-child(6),
  145. .css-slider .slide:focus ~ .slide:nth-child(6) { z-index:94; }
  146. .css-slider .slide:target ~ .slide:nth-child(7),
  147. .css-slider .slide:focus ~ .slide:nth-child(7) { z-index:93; }
  148. .css-slider .slide:target ~ .slide:nth-child(8),
  149. .css-slider .slide:focus ~ .slide:nth-child(8) { z-index:92; }
  150. .css-slider .slide:target ~ .slide:nth-child(9),
  151. .css-slider .slide:focus ~ .slide:nth-child(9) { z-index:91; }
  152. .css-slider .slide:target ~ .slide:nth-child(10),
  153. .css-slider .slide:focus ~ .slide:nth-child(10) { z-index:90; }
  154. .css-slider .slide:target ~ .slide:nth-child(11),
  155. .css-slider .slide:focus ~ .slide:nth-child(11) { z-index:89; }
  156. .css-slider .slide:target ~ .slide:nth-child(12),
  157. .css-slider .slide:focus ~ .slide:nth-child(12) { z-index:88; }
  158. .css-slider .slide:target ~ .slide:nth-child(13),
  159. .css-slider .slide:focus ~ .slide:nth-child(13) { z-index:87; }
  160. .css-slider .slide:target ~ .slide:nth-child(14),
  161. .css-slider .slide:focus ~ .slide:nth-child(14) { z-index:86; }
  162. .css-slider .slide:target ~ .slide:nth-child(15),
  163. .css-slider .slide:focus ~ .slide:nth-child(15) { z-index:85; }
  164. .css-slider .slide:target ~ .slide:nth-child(16),
  165. .css-slider .slide:focus ~ .slide:nth-child(16) { z-index:84; }
  166. .css-slider .slide:target ~ .slide:nth-child(17),
  167. .css-slider .slide:focus ~ .slide:nth-child(17) { z-index:83; }
  168. .css-slider .slide:target ~ .slide:nth-child(18),
  169. .css-slider .slide:focus ~ .slide:nth-child(18) { z-index:82; }
  170. .css-slider .slide:target ~ .slide:nth-child(19),
  171. .css-slider .slide:focus ~ .slide:nth-child(19) { z-index:81; }
  172. .css-slider .slide:target ~ .slide:nth-child(20),
  173. .css-slider .slide:focus ~ .slide:nth-child(20) { z-index:80; }
  174. /** --------------------------------------------------------------------------
  175. * HANDLE THE SLIDE ANIMATION (optional)
  176. * ------------------------------------------------------------------------ */
  177. /* Override the default instant slide behaviour */
  178. .css-slider .slide .slide-outer {
  179. display: block !important;
  180. display: table !important;
  181. }
  182. /* set up the transitions */
  183. .css-slider .slide .slide-outer {
  184. -webkit-transition-property: opacity, -wekbit-transform;
  185. -moz-transition-property: opacity, -moz-transform;
  186. -ms-transition-property: opacity, -ms-transform;
  187. -o-transition-property: opacity, -o-transform;
  188. transition-property: opacity, transform;
  189. -webkit-transition-duration: 0.5s;
  190. -moz-transition-duration: 0.5s;
  191. -ms-transition-duration: 0.5s;
  192. -o-transition-duration: 0.5s;
  193. transition-duration: 0.5s;
  194. -webkit-transition-timing-function: ease;
  195. -moz-transition-timing-function: ease;
  196. -ms-transition-timing-function: ease;
  197. -o-transition-timing-function: ease;
  198. transition-timing-function: ease;
  199. }
  200. /* After state */
  201. .css-slider .slide:target ~ .slide .slide-outer,
  202. .css-slider .slide:target ~ .slide:last-child .slide-outer,
  203. .css-slider .slide:focus ~ .slide .slide-outer,
  204. .css-slider .slide:focus ~ .slide:last-child .slide-outer {
  205. -webkit-transform: translate(-150%,0); -webkit-transform: translate3D(-150%,0,0);
  206. -moz-transform: translate(-150%,0); -moz-transform: translate3D(-150%,0,0);
  207. -ms-transform: translate(-150%,0); -ms-transform: translate3D(-150%,0,0);
  208. -o-transform: translate(-150%,0); -o-transform: translate3D(-150%,0,0);
  209. transform: translate(-150%,0); transform: translate3D(-150%,0,0);
  210. }
  211. /* Before state */
  212. .css-slider .slide .slide-outer {
  213. -webkit-transform: translate(200%,0); -webkit-transform: translate3D(200%,0,0);
  214. -moz-transform: translate(200%,0); -moz-transform: translate3D(200%,0,0);
  215. -ms-transform: translate(200%,0); -ms-transform: translate3D(200%,0,0);
  216. -o-transform: translate(200%,0); -o-transform: translate3D(200%,0,0);
  217. transform: translate(200%,0); transform: translate3D(200%,0,0);
  218. }
  219. /* Focused state*/
  220. .css-slider .slide:target .slide-outer,
  221. .css-slider .slide:focus .slide-outer,
  222. .css-slider .slide:last-child .slide-outer {
  223. -webkit-transform: translate(0,0); -webkit-transform: translate3D(0,0,0);
  224. -moz-transform: translate(0,0); -moz-transform: translate3D(0,0,0);
  225. -ms-transform: translate(0,0); -ms-transform: translate3D(0,0,0);
  226. -o-transform: translate(0,0); -o-transform: translate3D(0,0,0);
  227. transform: translate(0,0); transform: translate3D(0,0,0);
  228. }
  229. .slider-img {
  230. max-height:60vh;
  231. max-width:100%;
  232. display:block;
  233. }