爬行的蜗牛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: golang Linux PHP
查看: 139|回复: 0

HTML+CSS实现“玩家/用户卡”

[复制链接]

152

主题

48

回帖

1137

积分

管理员

积分
1137
发表于 2024-11-23 17:02:37 | 显示全部楼层 |阅读模式
这款卡片 UI 设计灵感来自双面收藏卡,悬停时会显示更多信息。卡片设计简洁明了,色彩丰富,非常适合用来展示数据。

效果
111.gif
HTML
  1. <div class="center">

  2.   <div class="card">
  3.     <div class="additional">
  4.       <div class="user-card">
  5.         <div class="level center">
  6.           Level 13
  7.         </div>
  8.         <div class="points center">
  9.           5,312 Points
  10.         </div>
  11.         <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">
  12.           <title id="title">Teacher</title>
  13.           <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>
  14.           <style>
  15.             .skin { fill: #eab38f; }
  16.             .eyes { fill: #1f1f1f; }
  17.             .hair { fill: #2f1b0d; }
  18.             .line { fill: none; stroke: #2f1b0d; stroke-width:2px; }
  19.           </style>
  20.           <defs>
  21.             <clipPath id="scene">
  22.               <circle cx="125" cy="125" r="115"/>
  23.             </clipPath>
  24.             <clipPath id="lips">
  25.               <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" />
  26.             </clipPath>
  27.           </defs>
  28.           <circle cx="125" cy="125" r="120" fill="rgba(0,0,0,0.15)" />
  29.           <g stroke="none" stroke-width="0" clip-path="url(#scene)">
  30.             <rect x="0" y="0" width="250" height="250" fill="#b0d2e5" />
  31.             <g id="head">
  32.               <path fill="none" stroke="#111111" stroke-width="2" d="M 68,103 83,103.5" />
  33.               <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" />
  34.               <circle cx="125" cy="100" r="55" class="skin" />
  35.               <ellipse cx="102" cy="107" rx="5" ry="5" class="eyes" id="eye-left" />
  36.               <ellipse cx="148" cy="107" rx="5" ry="5" class="eyes" id="eye-right" />
  37.               <rect x="119" y="140" width="12" height="40" class="skin" />
  38.               <path class="line eyebrow" d="M 90,98 C 93,90 103,89 110,94" id="eyebrow-left" />
  39.               <path class="line eyebrow" d="M 160,98 C 157,90 147,89 140,94" id="eyebrow-right"/>
  40.               <path stroke="#111111" stroke-width="4" d="M 68,103 83,102.5" />
  41.               <path stroke="#111111" stroke-width="4" d="M 182,103 167,102.5" />
  42.               <path stroke="#050505" stroke-width="3" fill="none" d="M 119,102 C 123,99 127,99 131,102" />
  43.               <path fill="#050505" d="M 92,97 C 85,97 79,98 80,101 81,104 84,104 85,102" />
  44.               <path fill="#050505" d="M 158,97 C 165,97 171,98 170,101 169,104 166,104 165,102" />
  45.               <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" />
  46.               <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" />
  47.               <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" />
  48.               <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" />
  49.               <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)" />
  50.             </g>
  51.             <g id="shirt">
  52.               <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"/>
  53.               <path id="arm-left" class="arm" stroke="#8665c2" fill="none" stroke-width="14" d="M 118,178 C 94,179 66,220 65,254" />
  54.               <path id="arm-right" class="arm" stroke="#8665c2" fill="none" stroke-width="14" d="M 132,178 C 156,179 184,220 185,254" />
  55.               <path fill="white" d="M 117,166 C 117,166 125,172 125,172 125,182 115,182 109,170 Z" />
  56.               <path fill="white" d="M 133,166 C 133,166 125,172 125,172 125,182 135,182 141,170 Z" />
  57.               <circle cx="125" cy="188" r="4" fill="#5a487b" />
  58.               <circle cx="125" cy="202" r="4" fill="#5a487b" />
  59.               <circle cx="125" cy="216" r="4" fill="#5a487b" />
  60.               <circle cx="125" cy="230" r="4" fill="#5a487b" />
  61.               <circle cx="125" cy="244" r="4" fill="#5a487b" />
  62.               <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" />
  63.               <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"/>
  64.             </g>
  65.           </g>
  66.         </svg>
  67.       </div>
  68.       <div class="more-info">
  69.         <h1>Jane Doe</h1>
  70.         <div class="coords">
  71.           <span>Group Name</span>
  72.           <span>Joined January 2019</span>
  73.         </div>
  74.         <div class="coords">
  75.           <span>Position/Role</span>
  76.           <span>City, Country</span>
  77.         </div>
  78.         <div class="stats">
  79.           <div>
  80.             <div class="title">Awards</div>
  81.             <i class="fa fa-trophy"></i>
  82.             <div class="value">2</div>
  83.           </div>
  84.           <div>
  85.             <div class="title">Matches</div>
  86.             <i class="fa fa-gamepad"></i>
  87.             <div class="value">27</div>
  88.           </div>
  89.           <div>
  90.             <div class="title">Pals</div>
  91.             <i class="fa fa-group"></i>
  92.             <div class="value">123</div>
  93.           </div>
  94.           <div>
  95.             <div class="title">Coffee</div>
  96.             <i class="fa fa-coffee"></i>
  97.             <div class="value infinity">∞</div>
  98.           </div>
  99.         </div>
  100.       </div>
  101.     </div>
  102.     <div class="general">
  103.       <h1>Jane Doe</h1>
  104.       <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce a volutpat mauris, at molestie lacus. Nam vestibulum sodales odio ut pulvinar.</p>
  105.       <span class="more">Mouse over the card for more info</span>
  106.     </div>
  107.   </div>

  108.   <div class="card green">
  109.     <div class="additional">
  110.       <div class="user-card">
  111.         <div class="level center">
  112.           Level 13
  113.         </div>
  114.         <div class="points center">
  115.           5,312 Points
  116.         </div>
  117.         <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">
  118.           <title id="title">Teacher</title>
  119.           <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>
  120.           <style>
  121.             .skin { fill: #eab38f; }
  122.             .eyes { fill: #1f1f1f; }
  123.             .hair { fill: #2f1b0d; }
  124.             .line { fill: none; stroke: #2f1b0d; stroke-width:2px; }
  125.           </style>
  126.           <defs>
  127.             <clipPath id="scene">
  128.               <circle cx="125" cy="125" r="115"/>
  129.             </clipPath>
  130.             <clipPath id="lips">
  131.               <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" />
  132.             </clipPath>
  133.           </defs>
  134.           <circle cx="125" cy="125" r="120" fill="rgba(0,0,0,0.15)" />
  135.           <g stroke="none" stroke-width="0" clip-path="url(#scene)">
  136.             <rect x="0" y="0" width="250" height="250" fill="#b0d2e5" />
  137.             <g id="head">
  138.               <path fill="none" stroke="#111111" stroke-width="2" d="M 68,103 83,103.5" />
  139.               <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" />
  140.               <circle cx="125" cy="100" r="55" class="skin" />
  141.               <ellipse cx="102" cy="107" rx="5" ry="5" class="eyes" id="eye-left" />
  142.               <ellipse cx="148" cy="107" rx="5" ry="5" class="eyes" id="eye-right" />
  143.               <rect x="119" y="140" width="12" height="40" class="skin" />
  144.               <path class="line eyebrow" d="M 90,98 C 93,90 103,89 110,94" id="eyebrow-left" />
  145.               <path class="line eyebrow" d="M 160,98 C 157,90 147,89 140,94" id="eyebrow-right"/>
  146.               <path stroke="#111111" stroke-width="4" d="M 68,103 83,102.5" />
  147.               <path stroke="#111111" stroke-width="4" d="M 182,103 167,102.5" />
  148.               <path stroke="#050505" stroke-width="3" fill="none" d="M 119,102 C 123,99 127,99 131,102" />
  149.               <path fill="#050505" d="M 92,97 C 85,97 79,98 80,101 81,104 84,104 85,102" />
  150.               <path fill="#050505" d="M 158,97 C 165,97 171,98 170,101 169,104 166,104 165,102" />
  151.               <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" />
  152.               <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" />
  153.               <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" />
  154.               <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" />
  155.               <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)" />
  156.             </g>
  157.             <g id="shirt">
  158.               <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"/>
  159.               <path id="arm-left" class="arm" stroke="#8665c2" fill="none" stroke-width="14" d="M 118,178 C 94,179 66,220 65,254" />
  160.               <path id="arm-right" class="arm" stroke="#8665c2" fill="none" stroke-width="14" d="M 132,178 C 156,179 184,220 185,254" />
  161.               <path fill="white" d="M 117,166 C 117,166 125,172 125,172 125,182 115,182 109,170 Z" />
  162.               <path fill="white" d="M 133,166 C 133,166 125,172 125,172 125,182 135,182 141,170 Z" />
  163.               <circle cx="125" cy="188" r="4" fill="#5a487b" />
  164.               <circle cx="125" cy="202" r="4" fill="#5a487b" />
  165.               <circle cx="125" cy="216" r="4" fill="#5a487b" />
  166.               <circle cx="125" cy="230" r="4" fill="#5a487b" />
  167.               <circle cx="125" cy="244" r="4" fill="#5a487b" />
  168.               <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" />
  169.               <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"/>
  170.             </g>
  171.           </g>
  172.         </svg>
  173.       </div>
  174.       <div class="more-info">
  175.         <h1>Jane Doe</h1>
  176.         <div class="coords">
  177.           <span>Group Name</span>
  178.           <span>Joined January 2019</span>
  179.         </div>
  180.         <div class="coords">
  181.           <span>Position/Role</span>
  182.           <span>City, Country</span>
  183.         </div>
  184.         <div class="stats">
  185.           <div>
  186.             <div class="title">Awards</div>
  187.             <i class="fa fa-trophy"></i>
  188.             <div class="value">2</div>
  189.           </div>
  190.           <div>
  191.             <div class="title">Matches</div>
  192.             <i class="fa fa-gamepad"></i>
  193.             <div class="value">27</div>
  194.           </div>
  195.           <div>
  196.             <div class="title">Pals</div>
  197.             <i class="fa fa-group"></i>
  198.             <div class="value">123</div>
  199.           </div>
  200.           <div>
  201.             <div class="title">Coffee</div>
  202.             <i class="fa fa-coffee"></i>
  203.             <div class="value infinity">∞</div>
  204.           </div>
  205.         </div>
  206.       </div>
  207.     </div>
  208.     <div class="general">
  209.       <h1>Jane Doe</h1>
  210.       <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce a volutpat mauris, at molestie lacus. Nam vestibulum sodales odio ut pulvinar.</p>
  211.       <span class="more">Mouse over the card for more info</span>
  212.     </div>
  213.   </div>

  214. </div>
复制代码
CSS
  1. @import url('https://fonts.googleapis.com/css?family=Abel');

  2. html, body {
  3.   background: #FCEEB5;
  4.   font-family: Abel, Arial, Verdana, sans-serif;
  5. }

  6. .center {
  7.   position: absolute;
  8.   top: 50%;
  9.   left: 50%;
  10.   -webkit-transform: translate(-50%, -50%);
  11. }

  12. .card {
  13.   width: 450px;
  14.   height: 250px;
  15.   background-color: #fff;
  16.   background: linear-gradient(#f8f8f8, #fff);
  17.   box-shadow: 0 8px 16px -8px rgba(0,0,0,0.4);
  18.   border-radius: 6px;
  19.   overflow: hidden;
  20.   position: relative;
  21.   margin: 1.5rem;
  22. }

  23. .card h1 {
  24.   text-align: center;
  25. }

  26. .card .additional {
  27.   position: absolute;
  28.   width: 150px;
  29.   height: 100%;
  30.   background: linear-gradient(#dE685E, #EE786E);
  31.   transition: width 0.4s;
  32.   overflow: hidden;
  33.   z-index: 2;
  34. }

  35. .card.green .additional {
  36.   background: linear-gradient(#92bCa6, #A2CCB6);
  37. }


  38. .card:hover .additional {
  39.   width: 100%;
  40.   border-radius: 0 5px 5px 0;
  41. }

  42. .card .additional .user-card {
  43.   width: 150px;
  44.   height: 100%;
  45.   position: relative;
  46.   float: left;
  47. }

  48. .card .additional .user-card::after {
  49.   content: "";
  50.   display: block;
  51.   position: absolute;
  52.   top: 10%;
  53.   right: -2px;
  54.   height: 80%;
  55.   border-left: 2px solid rgba(0,0,0,0.025);*/
  56. }

  57. .card .additional .user-card .level,
  58. .card .additional .user-card .points {
  59.   top: 15%;
  60.   color: #fff;
  61.   text-transform: uppercase;
  62.   font-size: 0.75em;
  63.   font-weight: bold;
  64.   background: rgba(0,0,0,0.15);
  65.   padding: 0.125rem 0.75rem;
  66.   border-radius: 100px;
  67.   white-space: nowrap;
  68. }

  69. .card .additional .user-card .points {
  70.   top: 85%;
  71. }

  72. .card .additional .user-card svg {
  73.   top: 50%;
  74. }

  75. .card .additional .more-info {
  76.   width: 300px;
  77.   float: left;
  78.   position: absolute;
  79.   left: 150px;
  80.   height: 100%;
  81. }

  82. .card .additional .more-info h1 {
  83.   color: #fff;
  84.   margin-bottom: 0;
  85. }

  86. .card.green .additional .more-info h1 {
  87.   color: #224C36;
  88. }

  89. .card .additional .coords {
  90.   margin: 0 1rem;
  91.   color: #fff;
  92.   font-size: 1rem;
  93. }

  94. .card.green .additional .coords {
  95.   color: #325C46;
  96. }

  97. .card .additional .coords span + span {
  98.   float: right;
  99. }

  100. .card .additional .stats {
  101.   font-size: 2rem;
  102.   display: flex;
  103.   position: absolute;
  104.   bottom: 1rem;
  105.   left: 1rem;
  106.   right: 1rem;
  107.   top: auto;
  108.   color: #fff;
  109. }

  110. .card.green .additional .stats {
  111.   color: #325C46;
  112. }

  113. .card .additional .stats > div {
  114.   flex: 1;
  115.   text-align: center;
  116. }

  117. .card .additional .stats i {
  118.   display: block;
  119. }

  120. .card .additional .stats div.title {
  121.   font-size: 0.75rem;
  122.   font-weight: bold;
  123.   text-transform: uppercase;
  124. }

  125. .card .additional .stats div.value {
  126.   font-size: 1.5rem;
  127.   font-weight: bold;
  128.   line-height: 1.5rem;
  129. }

  130. .card .additional .stats div.value.infinity {
  131.   font-size: 2.5rem;
  132. }

  133. .card .general {
  134.   width: 300px;
  135.   height: 100%;
  136.   position: absolute;
  137.   top: 0;
  138.   right: 0;
  139.   z-index: 1;
  140.   box-sizing: border-box;
  141.   padding: 1rem;
  142.   padding-top: 0;
  143. }

  144. .card .general .more {
  145.   position: absolute;
  146.   bottom: 1rem;
  147.   right: 1rem;
  148.   font-size: 0.9em;
  149. }
复制代码

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表