_carousels.scss 2.7 KB

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