当前位置:   article > 正文

HTML+CSS前端简单卡片动态效果_html中卡片样式

html中卡片样式

一、创意效果介绍

鼠标指针停在卡片上会有变色效果,点击还会有震动效果

二、效果视频

HTML+CSS前端简单卡片动态效果

三、设计代码

(1)HTML

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>简单卡片</title>
  6. <link
  7. rel="stylesheet"
  8. href="https://fonts.googleapis.com/css?family=Open+Sans"
  9. />
  10. <link rel="stylesheet" href="./style.css" />
  11. </head>
  12. <body>
  13. <!-- partial:index.partial.html -->
  14. <a href="#" class="card education">
  15. <div class="overlay"></div>
  16. <div class="circle">
  17. <svg
  18. width="71px"
  19. height="76px"
  20. viewBox="29 14 71 76"
  21. version="1.1"
  22. xmlns="http://www.w3.org/2000/svg"
  23. xmlns:xlink="http://www.w3.org/1999/xlink"
  24. >
  25. <desc>Created with Sketch.</desc>
  26. <defs></defs>
  27. <g
  28. id="Group"
  29. stroke="none"
  30. stroke-width="1"
  31. fill="none"
  32. fill-rule="evenodd"
  33. transform="translate(30.000000, 14.000000)"
  34. >
  35. <g id="Group-8" fill="#D98A19">
  36. <g id="Group-7">
  37. <g id="Group-6">
  38. <path
  39. d="M0,0 L0,75.9204805 L69.1511499,75.9204805 L0,0 Z M14.0563973,32.2825679 L42.9457663,63.9991501 L14.2315268,63.9991501 L14.0563973,32.2825679 Z"
  40. id="Fill-1"
  41. ></path>
  42. </g>
  43. </g>
  44. </g>
  45. <g
  46. id="Group-20"
  47. transform="translate(0.000000, 14.114286)"
  48. stroke="#FFFFFF"
  49. stroke-linecap="square"
  50. >
  51. <path d="M0.419998734,54.9642857 L4.70316223,54.9642857"></path>
  52. <path d="M0.419998734,50.4404762 L4.70316223,50.4404762"></path>
  53. <path d="M0.419998734,45.9166667 L4.70316223,45.9166667"></path>
  54. <path d="M0.419998734,41.3928571 L2.93999114,41.3928571"></path>
  55. <path d="M0.419998734,36.8690476 L4.70316223,36.8690476"></path>
  56. <path d="M0.419998734,32.3452381 L4.70316223,32.3452381"></path>
  57. <path d="M0.419998734,27.8214286 L4.70316223,27.8214286"></path>
  58. <path d="M0.419998734,23.297619 L2.93999114,23.297619"></path>
  59. <path d="M0.419998734,18.7738095 L4.70316223,18.7738095"></path>
  60. <path d="M0.419998734,14.25 L4.70316223,14.25"></path>
  61. <path d="M0.419998734,9.72619048 L4.70316223,9.72619048"></path>
  62. <path d="M0.419998734,5.20238095 L2.93999114,5.20238095"></path>
  63. <path
  64. d="M0.419998734,0.678571429 L4.70316223,0.678571429"
  65. id="Line1"
  66. ></path>
  67. </g>
  68. </g>
  69. </svg>
  70. </div>
  71. <p>Education</p>
  72. </a>
  73. <a href="#" class="card credentialing">
  74. <div class="overlay"></div>
  75. <div class="circle">
  76. <svg
  77. width="64px"
  78. height="72px"
  79. viewBox="27 21 64 72"
  80. version="1.1"
  81. xmlns="http://www.w3.org/2000/svg"
  82. xmlns:xlink="http://www.w3.org/1999/xlink"
  83. >
  84. <desc>Created with Sketch.</desc>
  85. <defs>
  86. <polygon
  87. id="path-1"
  88. points="60.9784821 18.4748913 60.9784821 0.0299638385 0.538377293 0.0299638385 0.538377293 18.4748913"
  89. ></polygon>
  90. </defs>
  91. <g
  92. id="Group-12"
  93. stroke="none"
  94. stroke-width="1"
  95. fill="none"
  96. fill-rule="evenodd"
  97. transform="translate(27.000000, 21.000000)"
  98. >
  99. <g id="Group-5">
  100. <g id="Group-3" transform="translate(2.262327, 21.615176)">
  101. <mask id="mask-2" fill="white">
  102. <use xlink:href="#path-1"></use>
  103. </mask>
  104. <g id="Clip-2"></g>
  105. <path
  106. d="M7.17774177,18.4748913 L54.3387782,18.4748913 C57.9910226,18.4748913 60.9789911,15.7266455 60.9789911,12.3681986 L60.9789911,6.13665655 C60.9789911,2.77820965 57.9910226,0.0299638385 54.3387782,0.0299638385 L7.17774177,0.0299638385 C3.52634582,0.0299638385 0.538377293,2.77820965 0.538377293,6.13665655 L0.538377293,12.3681986 C0.538377293,15.7266455 3.52634582,18.4748913 7.17774177,18.4748913"
  107. id="Fill-11"
  108. fill="#59A785"
  109. mask="url(#mask-2)"
  110. ></path>
  111. </g>
  112. <polygon
  113. id="Fill-4"
  114. fill="#FFFFFF"
  115. transform="translate(31.785111, 30.877531) rotate(-2.000000) translate(-31.785111, -30.877531) "
  116. points="62.0618351 55.9613216 7.2111488 60.3692832 1.50838775 5.79374073 56.3582257 1.38577917"
  117. ></polygon>
  118. <ellipse
  119. id="Oval-3"
  120. fill="#25D48A"
  121. opacity="0.216243004"
  122. cx="30.0584472"
  123. cy="21.7657707"
  124. rx="9.95169733"
  125. ry="9.17325562"
  126. ></ellipse>
  127. <g
  128. id="Group-4"
  129. transform="translate(16.959615, 6.479082)"
  130. fill="#54C796"
  131. >
  132. <polygon
  133. id="Fill-6"
  134. points="10.7955395 21.7823628 0.11873799 11.3001058 4.25482787 7.73131106 11.0226557 14.3753897 27.414824 1.77635684e-15 31.3261391 3.77891399"
  135. ></polygon>
  136. </g>
  137. <path
  138. d="M4.82347935,67.4368303 L61.2182039,67.4368303 C62.3304205,67.4368303 63.2407243,66.5995595 63.2407243,65.5765753 L63.2407243,31.3865871 C63.2407243,30.3636029 62.3304205,29.5263321 61.2182039,29.5263321 L4.82347935,29.5263321 C3.71126278,29.5263321 2.80095891,30.3636029 2.80095891,31.3865871 L2.80095891,65.5765753 C2.80095891,66.5995595 3.71126278,67.4368303 4.82347935,67.4368303"
  139. id="Fill-8"
  140. fill="#59B08B"
  141. ></path>
  142. <path
  143. d="M33.3338063,67.4368303 L61.2181191,67.4368303 C62.3303356,67.4368303 63.2406395,66.5995595 63.2406395,65.5765753 L63.2406395,31.3865871 C63.2406395,30.3636029 62.3303356,29.5263321 61.2181191,29.5263321 L33.3338063,29.5263321 C32.2215897,29.5263321 31.3112859,30.3636029 31.3112859,31.3865871 L31.3112859,65.5765753 C31.3112859,66.5995595 32.2215897,67.4368303 33.3338063,67.4368303"
  144. id="Fill-10"
  145. fill="#4FC391"
  146. ></path>
  147. <path
  148. d="M29.4284029,33.2640869 C29.4284029,34.2202068 30.2712569,34.9954393 31.3107768,34.9954393 C32.3502968,34.9954393 33.1931508,34.2202068 33.1931508,33.2640869 C33.1931508,32.3079669 32.3502968,31.5327345 31.3107768,31.5327345 C30.2712569,31.5327345 29.4284029,32.3079669 29.4284029,33.2640869"
  149. id="Fill-15"
  150. fill="#FEFEFE"
  151. ></path>
  152. <path
  153. d="M8.45417501,71.5549073 L57.5876779,71.5549073 C60.6969637,71.5549073 63.2412334,69.2147627 63.2412334,66.3549328 L63.2412334,66.3549328 C63.2412334,63.4951029 60.6969637,61.1549584 57.5876779,61.1549584 L8.45417501,61.1549584 C5.34488919,61.1549584 2.80061956,63.4951029 2.80061956,66.3549328 L2.80061956,66.3549328 C2.80061956,69.2147627 5.34488919,71.5549073 8.45417501,71.5549073"
  154. id="Fill-12"
  155. fill="#5BD6A2"
  156. ></path>
  157. </g>
  158. </g>
  159. </svg>
  160. </div>
  161. <p>Credentialing</p>
  162. </a>
  163. <a href="#" class="card wallet">
  164. <div class="overlay"></div>
  165. <div class="circle">
  166. <svg
  167. width="78px"
  168. height="60px"
  169. viewBox="23 29 78 60"
  170. version="1.1"
  171. xmlns="http://www.w3.org/2000/svg"
  172. xmlns:xlink="http://www.w3.org/1999/xlink"
  173. >
  174. <desc>Created with Sketch.</desc>
  175. <defs></defs>
  176. <g
  177. id="icon"
  178. stroke="none"
  179. stroke-width="1"
  180. fill="none"
  181. fill-rule="evenodd"
  182. transform="translate(23.000000, 29.500000)"
  183. >
  184. <rect
  185. id="Rectangle-3"
  186. fill="#AC8BE9"
  187. x="67.8357511"
  188. y="26.0333433"
  189. width="9.40495664"
  190. height="21.8788565"
  191. rx="4.70247832"
  192. ></rect>
  193. <rect
  194. id="Rectangle-31"
  195. fill="#6A5297"
  196. x="67.8357511"
  197. y="38.776399"
  198. width="9.40495664"
  199. height="10.962961"
  200. rx="4.70247832"
  201. ></rect>
  202. <polygon
  203. id="Rectangle-2"
  204. fill="#6A5297"
  205. points="57.3086772 0 67.1649301 26.3776902 14.4413177 45.0699507 4.58506484 18.6922605"
  206. ></polygon>
  207. <path
  208. d="M0,19.6104296 C0,16.2921718 2.68622235,13.6021923 5.99495032,13.6021923 L67.6438591,13.6021923 C70.9547788,13.6021923 73.6388095,16.2865506 73.6388095,19.6104296 L73.6388095,52.6639057 C73.6388095,55.9821635 70.9525871,58.672143 67.6438591,58.672143 L5.99495032,58.672143 C2.68403068,58.672143 0,55.9877847 0,52.6639057 L0,19.6104296 Z"
  209. id="Rectangle"
  210. fill="#8B6FC0"
  211. ></path>
  212. <path
  213. d="M47.5173769,27.0835169 C45.0052827,24.5377699 40.9347162,24.5377699 38.422622,27.0835169 L36.9065677,28.6198808 L35.3905134,27.0835169 C32.8799903,24.5377699 28.8078527,24.5377699 26.2957585,27.0835169 C23.7852354,29.6292639 23.7852354,33.7559532 26.2957585,36.3001081 L36.9065677,47.0530632 L47.5173769,36.3001081 C50.029471,33.7559532 50.029471,29.6292639 47.5173769,27.0835169"
  214. id="Fill-121"
  215. fill="#F6F1FF"
  216. ></path>
  217. <rect
  218. id="Rectangle-4"
  219. fill="#AC8BE9"
  220. x="58.0305835"
  221. y="26.1162588"
  222. width="15.6082259"
  223. height="12.863158"
  224. ></rect>
  225. <ellipse
  226. id="Oval"
  227. fill="#FFFFFF"
  228. cx="65.8346965"
  229. cy="33.0919007"
  230. rx="2.20116007"
  231. ry="2.23319575"
  232. ></ellipse>
  233. </g>
  234. </svg>
  235. </div>
  236. <p>Wallet</p>
  237. </a>
  238. <a href="#" class="card human-resources">
  239. <div class="overlay"></div>
  240. <div class="circle">
  241. <svg
  242. width="66px"
  243. height="77px"
  244. viewBox="1855 26 66 77"
  245. version="1.1"
  246. xmlns="http://www.w3.org/2000/svg"
  247. xmlns:xlink="http://www.w3.org/1999/xlink"
  248. >
  249. <desc>Created with Sketch.</desc>
  250. <defs></defs>
  251. <g
  252. id="Page-1"
  253. stroke="none"
  254. stroke-width="1"
  255. fill="none"
  256. fill-rule="evenodd"
  257. transform="translate(1855.000000, 26.000000)"
  258. >
  259. <path
  260. d="M4.28872448,42.7464904 C4.28872448,39.3309774 5.4159227,33.7621426 6.40576697,30.4912557 C10.5920767,32.1098991 14.3021264,35.1207513 18.69596,35.1207513 C30.993618,35.1207513 42.5761396,28.7162991 49.9992251,17.9014817 C56.8027248,23.8881252 60.8188351,33.0463165 60.8188351,42.7464904 C60.8188351,60.817447 47.6104607,76.6693426 32.5537798,76.6693426 C17.4970989,76.6693426 4.28872448,60.817447 4.28872448,42.7464904"
  261. id="Fill-81"
  262. fill="#AFCEFF"
  263. ></path>
  264. <path
  265. d="M64.3368879,31.1832696 L62.8424171,46.6027478 L60.6432609,46.7824348 L59.8340669,34.6791304 L47.6573402,25.3339478 C44.2906753,34.068487 34.3459503,40.2903304 24.4684093,40.2903304 C17.7559812,40.2903304 10.046244,37.4168 5.80469412,32.8004522 L5.80469412,34.6791304 L5.80469412,46.6027478 L4.28932167,46.6027478 L1.30187314,27.8802435 C1.30187314,20.9790957 3.52342407,15.5432 7.27229127,11.3578087 C13.132229,4.79558261 21.8124018,0.0492173913 30.5672235,0.342852174 C37.4603019,0.569286957 42.6678084,2.72991304 50.8299179,0.342852174 C51.4629405,1.44434783 51.8615656,3.00455652 51.5868577,5.22507826 C51.4629405,6.88316522 51.2106273,7.52302609 50.8299179,8.45067826 C58.685967,14.1977391 64.3368879,20.7073739 64.3368879,31.1832696"
  266. id="Fill-101"
  267. fill="#3B6CB7"
  268. ></path>
  269. <path
  270. d="M58.9405197,54.5582052 C62.0742801,54.8270052 65.3603242,52.60064 65.6350321,49.5386574 C65.772386,48.009127 65.2617876,46.5570226 64.3182257,45.4584487 C63.3761567,44.3613357 62.0205329,43.6162922 60.4529062,43.4818922 L58.9405197,54.5582052 Z"
  271. id="Fill-13"
  272. fill="#568ADC"
  273. ></path>
  274. <path
  275. d="M6.32350389,54.675367 C3.18227865,54.8492104 0.484467804,52.4957496 0.306803449,49.4264626 C0.217224782,47.8925496 0.775598471,46.4579757 1.75200594,45.3886191 C2.7284134,44.3192626 4.10792487,43.6165843 5.67853749,43.530393 L6.32350389,54.675367 Z"
  276. id="Fill-151"
  277. fill="#568ADC"
  278. ></path>
  279. </g>
  280. </svg>
  281. </div>
  282. <p>Human Resources</p>
  283. </a>
  284. <!-- partial -->
  285. </body>
  286. </html>

(2)CSS

  1. body {
  2. background: #f2f4f8;
  3. display: flex;
  4. justify-content: space-around;
  5. align-items: center;
  6. flex-wrap: wrap;
  7. height: 100vh;
  8. font-family: "Open Sans";
  9. }
  10. .education {
  11. --bg-color: #ffd861;
  12. --bg-color-light: #ffeeba;
  13. --text-color-hover: #4c5656;
  14. --box-shadow-color: rgba(255, 215, 97, 0.48);
  15. }
  16. .credentialing {
  17. --bg-color: #b8f9d3;
  18. --bg-color-light: #e2fced;
  19. --text-color-hover: #4c5656;
  20. --box-shadow-color: rgba(184, 249, 211, 0.48);
  21. }
  22. .wallet {
  23. --bg-color: #ceb2fc;
  24. --bg-color-light: #f0e7ff;
  25. --text-color-hover: #fff;
  26. --box-shadow-color: rgba(206, 178, 252, 0.48);
  27. }
  28. .human-resources {
  29. --bg-color: #dce9ff;
  30. --bg-color-light: #f1f7ff;
  31. --text-color-hover: #4c5656;
  32. --box-shadow-color: rgba(220, 233, 255, 0.48);
  33. }
  34. .card {
  35. width: 220px;
  36. height: 321px;
  37. background: #fff;
  38. border-top-right-radius: 10px;
  39. overflow: hidden;
  40. display: flex;
  41. flex-direction: column;
  42. justify-content: center;
  43. align-items: center;
  44. position: relative;
  45. box-shadow: 0 14px 26px rgba(0, 0, 0, 0.04);
  46. transition: all 0.3s ease-out;
  47. text-decoration: none;
  48. }
  49. .card:hover {
  50. transform: translateY(-5px) scale(1.005) translateZ(0);
  51. box-shadow: 0 24px 36px rgba(0, 0, 0, 0.11),
  52. 0 24px 46px var(--box-shadow-color);
  53. }
  54. .card:hover .overlay {
  55. transform: scale(4) translateZ(0);
  56. }
  57. .card:hover .circle {
  58. border-color: var(--bg-color-light);
  59. background: var(--bg-color);
  60. }
  61. .card:hover .circle:after {
  62. background: var(--bg-color-light);
  63. }
  64. .card:hover p {
  65. color: var(--text-color-hover);
  66. }
  67. .card:active {
  68. transform: scale(1) translateZ(0);
  69. box-shadow: 0 15px 24px rgba(0, 0, 0, 0.11),
  70. 0 15px 24px var(--box-shadow-color);
  71. }
  72. .card p {
  73. font-size: 17px;
  74. color: #4c5656;
  75. margin-top: 30px;
  76. z-index: 1000;
  77. transition: color 0.3s ease-out;
  78. }
  79. .circle {
  80. width: 131px;
  81. height: 131px;
  82. border-radius: 50%;
  83. background: #fff;
  84. border: 2px solid var(--bg-color);
  85. display: flex;
  86. justify-content: center;
  87. align-items: center;
  88. position: relative;
  89. z-index: 1;
  90. transition: all 0.3s ease-out;
  91. }
  92. .circle:after {
  93. content: "";
  94. width: 118px;
  95. height: 118px;
  96. display: block;
  97. position: absolute;
  98. background: var(--bg-color);
  99. border-radius: 50%;
  100. top: 7px;
  101. left: 7px;
  102. transition: opacity 0.3s ease-out;
  103. }
  104. .circle svg {
  105. z-index: 10000;
  106. transform: translateZ(0);
  107. }
  108. .overlay {
  109. width: 118px;
  110. position: absolute;
  111. height: 118px;
  112. border-radius: 50%;
  113. background: var(--bg-color);
  114. top: 70px;
  115. left: 50px;
  116. z-index: 0;
  117. transition: transform 0.3s ease-out;
  118. }

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号