_carousels.scss 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // Carousels
  2. // The number of carousel images
  3. $carousel-number: 8;
  4. %carousel-image-checked {
  5. animation: carousel-slidein .75s ease-in-out 1;
  6. opacity: 1;
  7. z-index: $zindex-1;
  8. }
  9. %carousel-nav-checked {
  10. color: $gray-color-light;
  11. }
  12. .carousel {
  13. background: $bg-color;
  14. display: block;
  15. overflow: hidden;
  16. position: relative;
  17. width: 100%;
  18. -webkit-overflow-scrolling: touch;
  19. z-index: $zindex-0;
  20. .carousel-container {
  21. height: 100%;
  22. left: 0;
  23. position: relative;
  24. &::before {
  25. content: "";
  26. display: block;
  27. padding-bottom: 56.25%;
  28. }
  29. .carousel-item {
  30. animation: carousel-slideout 1s ease-in-out 1;
  31. height: 100%;
  32. left: 0;
  33. margin: 0;
  34. opacity: 0;
  35. position: absolute;
  36. top: 0;
  37. width: 100%;
  38. &:hover {
  39. .item-prev,
  40. .item-next {
  41. opacity: 1;
  42. }
  43. }
  44. }
  45. .item-prev,
  46. .item-next {
  47. background: rgba($gray-color-light, .25);
  48. border-color: rgba($gray-color-light, .5);
  49. color: $gray-color-light;
  50. opacity: 0;
  51. position: absolute;
  52. top: 50%;
  53. transition: all .4s;
  54. transform: translateY(-50%);
  55. z-index: $zindex-1;
  56. }
  57. .item-prev {
  58. left: 1rem;
  59. }
  60. .item-next {
  61. right: 1rem;
  62. }
  63. }
  64. .carousel-locator {
  65. @for $i from 1 through ($carousel-number) {
  66. &:nth-of-type(#{$i}):checked ~ .carousel-container .carousel-item:nth-of-type(#{$i}) {
  67. @extend %carousel-image-checked;
  68. }
  69. }
  70. @for $i from 1 through ($carousel-number) {
  71. &:nth-of-type(#{$i}):checked ~ .carousel-nav .nav-item:nth-of-type(#{$i}) {
  72. @extend %carousel-nav-checked;
  73. }
  74. }
  75. }
  76. .carousel-nav {
  77. bottom: $layout-spacing;
  78. display: flex;
  79. justify-content: center;
  80. left: 50%;
  81. position: absolute;
  82. transform: translateX(-50%);
  83. width: 10rem;
  84. z-index: $zindex-1;
  85. .nav-item {
  86. color: rgba($gray-color-light, .5);
  87. display: block;
  88. flex: 1 0 auto;
  89. height: $unit-8;
  90. margin: $unit-1;
  91. max-width: 2.5rem;
  92. position: relative;
  93. &::before {
  94. background: currentColor;
  95. content: "";
  96. display: block;
  97. height: $unit-h;
  98. position: absolute;
  99. top: .5rem;
  100. width: 100%;
  101. }
  102. }
  103. }
  104. }
  105. @keyframes carousel-slidein {
  106. 0% {
  107. transform: translateX(100%);
  108. }
  109. 100% {
  110. transform: translateX(0);
  111. }
  112. }
  113. @keyframes carousel-slideout {
  114. 0% {
  115. opacity: 1;
  116. transform: translateX(0);
  117. }
  118. 100% {
  119. opacity: 1;
  120. transform: translateX(-50%);
  121. }
  122. }