图片/图形

纯CSS3用户卡片设计效果

阿里云


这是一款纯 CSS3 用户卡片设计效果。该卡片设计效果结合 SVG 来制作,在鼠标 hover 卡片时,产生炫酷的动画效果。

使用方法

在页面中引入 font-awesome 文件。

也想出现在这里?联系我们
创客主机
  1. <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" />

HTML 结构

基本 HTML DOM 结构如下:

  1. <div class="card">
  2.     <div class="additional">
  3.       <div class="user-card">
  4.         <div class="level center">
  5.           Level 13
  6.         </div>
  7.         <div class="points center">
  8.           5,312 Points
  9.         </div>
  10.         <svg width="110" height="110" viewBox="0 0 250 250" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="title desc" class="center">
  11.           <title id="title">Teacher</title>
  12.           <desc id="desc">Cartoon of a Caucasian woman smiling, and wearing black glasses and a purple shirt with white collar drawn by Alvaro Montoro.</desc>
  13.           <style>
  14.             .skin { fill: #eab38f; }
  15.             .eyes { fill: #1f1f1f; }
  16.             .hair { fill: #2f1b0d; }
  17.             .line { fill: none; stroke: #2f1b0d; stroke-width:2px; }
  18.           </style>
  19.           <defs>
  20.             <clipPath id="scene">
  21.               <circle cx="125" cy="125" r="115"/>
  22.             </clipPath>
  23.             <clipPath id="lips">
  24.               <path d="M 106,132 C 113,127 125,128 125,132 125,128 137,127 144,132 141,142  134,146  125,146  116,146 109,142 106,132 Z" />
  25.             </clipPath>
  26.           </defs>
  27.           <circle cx="125" cy="125" r="120" fill="rgba(0,0,0,0.15)" />
  28.           <g stroke="none" stroke-width="0" clip-path="url(#scene)">
  29.             <rect x="0" y="0" width="250" height="250" fill="#b0d2e5" />
  30.             <g id="head">
  31.               <path fill="none" stroke="#111111" stroke-width="2" d="M 68,103 83,103.5" />
  32.               <path class="hair" d="M 67,90 67,169 78,164 89,169 100,164 112,169 125,164 138,169 150,164 161,169 172,164 183,169 183,90 Z" />
  33.               <circle cx="125" cy="100" r="55" class="skin" />
  34.               <ellipse cx="102" cy="107" rx="5" ry="5" class="eyes" id="eye-left" />
  35.               <ellipse cx="148" cy="107" rx="5" ry="5" class="eyes" id="eye-right" />
  36.               <rect x="119" y="140" width="12" height="40" class="skin" />
  37.               <path class="line eyebrow" d="M 90,98 C 93,90 103,89 110,94" id="eyebrow-left" />
  38.               <path class="line eyebrow" d="M 160,98 C 157,90 147,89 140,94" id="eyebrow-right"/>
  39.               <path stroke="#111111" stroke-width="4" d="M 68,103 83,102.5" />
  40.               <path stroke="#111111" stroke-width="4" d="M 182,103 167,102.5" />
  41.               <path stroke="#050505" stroke-width="3" fill="none" d="M 119,102 C 123,99 127,99 131,102" />
  42.               <path fill="#050505" d="M 92,97 C 85,97 79,98 80,101 81,104 84,104 85,102" />
  43.               <path fill="#050505" d="M 158,97 C 165,97 171,98 170,101 169,104 166,104 165,102" />
  44.               <path stroke="#050505" stroke-width="3" fill="rgba(240,240,255,0.4)" d="M 119,102 C 118,111 115,119 98,117 85,115 84,108 84,104 84,97 94,96 105,97 112,98 117,98 119,102 Z" />
  45.               <path stroke="#050505" stroke-width="3" fill="rgba(240,240,255,0.4)" d="M 131,102 C 132,111 135,119 152,117 165,115 166,108 166,104 166,97 156,96 145,97 138,98 133,98 131,102 Z" />
  46.               <path class="hair" d="M 60,109 C 59,39 118,40 129,40 139,40 187,43 189,99 135,98 115,67 115,67 115,67 108,90 80,109 86,101 91,92 92,87 85,99 65,108 60,109" />
  47.               <path id="mouth" fill="#d73e3e" d="M 106,132 C 113,127 125,128 125,132 125,128 137,127 144,132 141,142  134,146  125,146  116,146 109,142 106,132 Z" /> 
  48.               <path id="smile" fill="white" d="M125,141 C 140,141 143,132 143,132 143,132 125,133 125,133 125,133 106.5,132 106.5,132 106.5,132 110,141 125,141 Z" clip-path="url(#lips)" />
  49.             </g>
  50.             <g id="shirt">
  51.               <path fill="#8665c2" d="M 132,170 C 146,170 154,200 154,200 154,200 158,250 158,250 158,250 92,250 92,250 92,250 96,200 96,200 96,200 104,170 118,170 118,170 125,172 125,172 125,172 132,170 132,170 Z"/>
  52.               <path id="arm-left" class="arm" stroke="#8665c2" fill="none" stroke-width="14" d="M 118,178 C 94,179 66,220 65,254" />
  53.               <path id="arm-right" class="arm" stroke="#8665c2" fill="none" stroke-width="14" d="M 132,178 C 156,179 184,220 185,254" />
  54.               <path fill="white" d="M 117,166 C 117,166 125,172 125,172 125,182 115,182 109,170 Z" />
  55.               <path fill="white" d="M 133,166 C 133,166 125,172 125,172 125,182 135,182 141,170 Z" />
  56.               <circle cx="125" cy="188" r="4" fill="#5a487b" />
  57.               <circle cx="125" cy="202" r="4" fill="#5a487b" />
  58.               <circle cx="125" cy="216" r="4" fill="#5a487b" />
  59.               <circle cx="125" cy="230" r="4" fill="#5a487b" />
  60.               <circle cx="125" cy="244" r="4" fill="#5a487b" />
  61.               <path stroke="#daa37f" stroke-width="1" class="skin hand" id="hand-left" d="M 51,270 C 46,263 60,243 63,246 65,247 66,248 61,255 72,243 76,238 79,240 82,243 72,254 69,257 72,254 82,241 86,244 89,247 75,261 73,263 77,258 84,251 86,253 89,256 70,287 59,278" /> 
  62.               <path stroke="#daa37f" stroke-width="1" class="skin hand" id="hand-right" d="M 199,270 C 204,263 190,243 187,246 185,247 184,248 189,255 178,243 174,238 171,240 168,243 178,254 181,257 178,254 168,241 164,244 161,247 175,261 177,263 173,258 166,251 164,253 161,256 180,287 191,278"/> 
  63.             </g>
  64.           </g>
  65.         </svg>
  66.       </div>
  67.       <div class="more-info">
  68.         <h1>Jane Doe</h1>
  69.         <div class="coords">
  70.           <span>Group Name</span>
  71.           <span>Joined January 2019</span>
  72.         </div>
  73.         <div class="coords">
  74.           <span>Position/Role</span>
  75.           <span>City, Country</span>
  76.         </div>
  77.         <div class="stats">
  78.           <div>
  79.             <div class="title">Awards</div>
  80.             <i class="fa fa-trophy"></i>
  81.             <div class="value">2</div>
  82.           </div>
  83.           <div>
  84.             <div class="title">Matches</div>
  85.             <i class="fa fa-gamepad"></i>
  86.             <div class="value">27</div>
  87.           </div>
  88.           <div>
  89.             <div class="title">Pals</div>
  90.             <i class="fa fa-group"></i>
  91.             <div class="value">123</div>
  92.           </div>
  93.           <div>
  94.             <div class="title">Coffee</div>
  95.             <i class="fa fa-coffee"></i>
  96.             <div class="value infinity"></div>
  97.           </div>
  98.         </div>
  99.       </div>
  100.     </div>
  101.     <div class="general">
  102.       <h1>Jane Doe</h1>
  103.       <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce a volutpat mauris, at molestie lacus. Nam vestibulum sodales odio ut pulvinar.</p>
  104.       <span class="more">Mouse over the card for more info</span>
  105.     </div>
  106.  </div>

CSS 样式

然后为卡片添加下面的 CSS 样式。

  1. .card {
  2.   width: 450px;
  3.   height: 250px;
  4.   background-color: #fff;
  5.   background: linear-gradient(#f8f8f8, #fff);
  6.   box-shadow: 0 8px 16px -8px rgba(0,0,0,0.4);
  7.   border-radius: 6px;
  8.   overflow: hidden;
  9.   position: relative;
  10.   margin: 1.5rem;
  11. }
  12.  
  13. .card h1 {
  14.   text-align: center;
  15. }
  16.  
  17. .card .additional {
  18.   position: absolute;
  19.   width: 150px;
  20.   height: 100%;
  21.   background: linear-gradient(#dE685E, #EE786E);
  22.   transition: width 0.4s;
  23.   overflow: hidden;
  24.   z-index: 2;
  25. }
  26.  
  27. .card.green .additional {
  28.   background: linear-gradient(#92bCa6, #A2CCB6);
  29. }
  30.  
  31.  
  32. .card:hover .additional {
  33.   width: 100%;
  34.   border-radius: 0 5px 5px 0;
  35. }
  36.  
  37. .card .additional .user-card {
  38.   width: 150px;
  39.   height: 100%;
  40.   position: relative;
  41.   float: left;
  42. }
  43.  
  44. .card .additional .user-card::after {
  45.   content: "";
  46.   display: block;
  47.   position: absolute;
  48.   top: 10%;
  49.   right: -2px;
  50.   height: 80%;
  51.   border-left: 2px solid rgba(0,0,0,0.025);*/
  52. }
  53.  
  54. .card .additional .user-card .level,
  55. .card .additional .user-card .points {
  56.   top: 15%;
  57.   color: #fff;
  58.   text-transform: uppercase;
  59.   font-size: 0.75em;
  60.   font-weight: bold;
  61.   background: rgba(0,0,0,0.15);
  62.   padding: 0.125rem 0.75rem;
  63.   border-radius: 100px;
  64.   white-space: nowrap;
  65. }
  66.  
  67. .card .additional .user-card .points {
  68.   top: 85%;
  69. }
  70.  
  71. .card .additional .user-card svg {
  72.   top: 50%;
  73. }
  74.  
  75. .card .additional .more-info {
  76.   width: 300px;
  77.   float: left;
  78.   position: absolute;
  79.   left: 150px;
  80.   height: 100%;
  81. }
  82.  
  83. .card .additional .more-info h1 {
  84.   color: #fff;
  85.   margin-bottom: 0;
  86. }
  87.  
  88. .card.green .additional .more-info h1 {
  89.   color: #224C36;
  90. }
  91.  
  92. .card .additional .coords {
  93.   margin: 0 1rem;
  94.   color: #fff;
  95.   font-size: 1rem;
  96. }
  97.  
  98. .card.green .additional .coords {
  99.   color: #325C46;
  100. }
  101.  
  102. .card .additional .coords span + span {
  103.   float: right;
  104. }
  105.  
  106. .card .additional .stats {
  107.   font-size: 2rem;
  108.   display: flex;
  109.   position: absolute;
  110.   bottom: 1rem;
  111.   left: 1rem;
  112.   right: 1rem;
  113.   top: auto;
  114.   color: #fff;
  115. }
  116.  
  117. .card.green .additional .stats {
  118.   color: #325C46;
  119. }
  120.  
  121. .card .additional .stats > div {
  122.   flex: 1;
  123.   text-align: center;
  124. }
  125.  
  126. .card .additional .stats i {
  127.   display: block;
  128. }
  129.  
  130. .card .additional .stats div.title {
  131.   font-size: 0.75rem;
  132.   font-weight: bold;
  133.   text-transform: uppercase;
  134. }
  135.  
  136. .card .additional .stats div.value {
  137.   font-size: 1.5rem;
  138.   font-weight: bold;
  139.   line-height: 1.5rem;
  140. }
  141.  
  142. .card .additional .stats div.value.infinity {
  143.   font-size: 2.5rem;
  144. }
  145.  
  146. .card .general {
  147.   width: 300px;
  148.   height: 100%;
  149.   position: absolute;
  150.   top: 0;
  151.   right: 0;
  152.   z-index: 1;
  153.   box-sizing: border-box;
  154.   padding: 1rem;
  155.   padding-top: 0;
  156. }
  157.  
  158. .card .general .more {
  159.   position: absolute;
  160.   bottom: 1rem;
  161.   right: 1rem;
  162.   font-size: 0.9em;
  163. }

Codepen 网址:https://codepen.io/alvaromontoro/pen/ebPEWb

纯 CSS3 用户卡片设计效果

已有 1046 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!