_parallax.scss 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // Parallax
  2. $parallax-deg: 3deg !default;
  3. $parallax-offset: 4.5px !default;
  4. $parallax-offset-z: 50px !default;
  5. $parallax-perspective: 1000px !default;
  6. $parallax-scale: .95 !default;
  7. $parallax-fade-color: rgba(255, 255, 255, .35) !default;
  8. // Mixin: Parallax direction
  9. @mixin parallax-dir() {
  10. height: 50%;
  11. outline: none;
  12. position: absolute;
  13. width: 50%;
  14. z-index: $zindex-1;
  15. }
  16. .parallax {
  17. display: block;
  18. height: auto;
  19. position: relative;
  20. width: auto;
  21. .parallax-content {
  22. @include shadow-variant(1rem);
  23. height: auto;
  24. transform: perspective($parallax-perspective);
  25. transform-style: preserve-3d;
  26. transition: all .4s ease;
  27. width: 100%;
  28. &::before {
  29. content: "";
  30. display: block;
  31. height: 100%;
  32. left: 0;
  33. position: absolute;
  34. top: 0;
  35. width: 100%;
  36. }
  37. }
  38. .parallax-front {
  39. align-items: center;
  40. color: $light-color;
  41. display: flex;
  42. height: 100%;
  43. justify-content: center;
  44. left: 0;
  45. position: absolute;
  46. text-align: center;
  47. text-shadow: 0 0 20px rgba($dark-color, .75);
  48. top: 0;
  49. transform: translateZ($parallax-offset-z) scale($parallax-scale);
  50. transition: all .4s ease;
  51. width: 100%;
  52. z-index: $zindex-0;
  53. }
  54. .parallax-top-left {
  55. @include parallax-dir();
  56. left: 0;
  57. top: 0;
  58. &:focus ~ .parallax-content,
  59. &:hover ~ .parallax-content {
  60. transform: perspective($parallax-perspective) rotateX($parallax-deg) rotateY(-$parallax-deg);
  61. &::before {
  62. background: linear-gradient(135deg, $parallax-fade-color 0%, transparent 50%);
  63. }
  64. .parallax-front {
  65. transform: translate3d($parallax-offset, $parallax-offset, $parallax-offset-z) scale($parallax-scale);
  66. }
  67. }
  68. }
  69. .parallax-top-right {
  70. @include parallax-dir();
  71. right: 0;
  72. top: 0;
  73. &:focus ~ .parallax-content,
  74. &:hover ~ .parallax-content {
  75. transform: perspective($parallax-perspective) rotateX($parallax-deg) rotateY($parallax-deg);
  76. &::before {
  77. background: linear-gradient(-135deg, $parallax-fade-color 0%, transparent 50%);
  78. }
  79. .parallax-front {
  80. transform: translate3d(-$parallax-offset, $parallax-offset, $parallax-offset-z) scale($parallax-scale);
  81. }
  82. }
  83. }
  84. .parallax-bottom-left {
  85. @include parallax-dir();
  86. bottom: 0;
  87. left: 0;
  88. &:focus ~ .parallax-content,
  89. &:hover ~ .parallax-content {
  90. transform: perspective($parallax-perspective) rotateX(-$parallax-deg) rotateY(-$parallax-deg);
  91. &::before {
  92. background: linear-gradient(45deg, $parallax-fade-color 0%, transparent 50%);
  93. }
  94. .parallax-front {
  95. transform: translate3d($parallax-offset, -$parallax-offset, $parallax-offset-z) scale($parallax-scale);
  96. }
  97. }
  98. }
  99. .parallax-bottom-right {
  100. @include parallax-dir();
  101. bottom: 0;
  102. right: 0;
  103. &:focus ~ .parallax-content,
  104. &:hover ~ .parallax-content {
  105. transform: perspective($parallax-perspective) rotateX(-$parallax-deg) rotateY($parallax-deg);
  106. &::before {
  107. background: linear-gradient(-45deg, $parallax-fade-color 0%, transparent 50%);
  108. }
  109. .parallax-front {
  110. transform: translate3d(-$parallax-offset, -$parallax-offset, $parallax-offset-z) scale($parallax-scale);
  111. }
  112. }
  113. }
  114. }