当前位置:   article > 正文

【前端】卡片渐变色阴影效果 旋转动画_前端 card加阴影

前端 card加阴影

【前端】卡片渐变色阴影效果 旋转动画

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Breathing Effect</title>
  7. <style>
  8. @property --rotate {
  9. syntax: "<angle>";
  10. initial-value: 132deg;
  11. inherits: false;
  12. }
  13. :root {
  14. --card-height: 65vh;
  15. --card-width: calc(var(--card-height) / 1.5);
  16. }
  17. body {
  18. min-height: 100vh;
  19. background: #212534;
  20. display: flex;
  21. align-items: center;
  22. flex-direction: column;
  23. padding-top: 2rem;
  24. padding-bottom: 2rem;
  25. box-sizing: border-box;
  26. }
  27. .card {
  28. background: #191c29;
  29. width: var(--card-width);
  30. height: var(--card-height);
  31. padding: 3px;
  32. position: relative;
  33. border-radius: 6px;
  34. justify-content: center;
  35. align-items: center;
  36. text-align: center;
  37. display: flex;
  38. font-size: 1.5em;
  39. color: rgb(88 199 250 / 0%);
  40. cursor: pointer;
  41. font-family: cursive;
  42. }
  43. .card:hover {
  44. color: rgb(88 199 250 / 100%);
  45. transition: color 1s;
  46. }
  47. .card:hover:before, .card:hover:after {
  48. animation: none;
  49. opacity: 0;
  50. }
  51. .card::before {
  52. content: "";
  53. width: 104%;
  54. height: 102%;
  55. border-radius: 8px;
  56. background-image: linear-gradient(
  57. var(--rotate)
  58. , #5ddcff, #3c67e3 43%, #4e00c2);
  59. position: absolute;
  60. z-index: -1;
  61. top: -1%;
  62. left: -2%;
  63. animation: spin 2.5s linear infinite;
  64. }
  65. .card::after {
  66. position: absolute;
  67. content: "";
  68. top: calc(var(--card-height) / 6);
  69. left: 0;
  70. right: 0;
  71. z-index: -1;
  72. height: 100%;
  73. width: 100%;
  74. margin: 0 auto;
  75. transform: scale(0.8);
  76. filter: blur(calc(var(--card-height) / 6));
  77. background-image: linear-gradient(
  78. var(--rotate)
  79. , #5ddcff, #3c67e3 43%, #4e00c2);
  80. opacity: 1;
  81. transition: opacity .5s;
  82. animation: spin 2.5s linear infinite;
  83. }
  84. @keyframes spin {
  85. 0% {
  86. --rotate: 0deg;
  87. }
  88. 100% {
  89. --rotate: 360deg;
  90. }
  91. }
  92. a {
  93. color: #212534;
  94. text-decoration: none;
  95. font-family: sans-serif;
  96. font-weight: bold;
  97. margin-top: 2rem;
  98. }
  99. </style>
  100. </head>
  101. <body>
  102. <div class="card">
  103. Magic Card
  104. </div>
  105. </body>
  106. </html>

参考

Magic Card (codepen.io)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/851696
推荐阅读
相关标签
  

闽ICP备14008679号