css实现带tab选项卡切换的个人信息卡片效果代码
代码语言:html
所属分类:选项卡
代码描述:css实现带tab选项卡切换的个人信息卡片效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap" rel="stylesheet"> <style> :root { --primary: #5F5DFE; --primary-darker: #4F4DFE; --bg: #EFF3F4; --white: #FFF; --profile-bg: #FFFFFD; --socials-bg: #F9FAFC; --highlight-bg: #F9FAFC; --text-bg: #878789; --text: #797C83; --border-color: #F4F4F4; --social-color: #6B6C6E; --active: #7774B5; --tab-bg: #EBE9FF; --tabs-border: #F2F6F5; --tab-width: 7rem; --tabs-gap: 0rem; --tab-radius: 0.4rem; --scrollbar-thumb: #e4e3f3; --scrollbar-bg: #F2F6F5; } * { margin: 0; padding: 0; box-sizing: border-box; } *:focus { outline: 1px solid var(--primary); outline-offset: 0; } *::selection { background: var(--primary); color: var(--white); } *::-webkit-scrollbar { width: 0.5rem; height: 0.5rem; background: var(--scrollbar-bg); border-radius: 9.99rem; } *::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 9.99rem; } body { font-family: 'Manrope', sans-serif; background: var(--bg); color: var(--text); display: flex; justify-content: center; flex-direction: column; height: 100vh; user-select: none; } .profile { background: var(--profile-bg); padding: 1rem; border-radius: 1rem; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); width: 100%; max-width: 28rem; min-width: 20rem; margin: 0 auto; gap: 0.75rem; display: flex; flex-direction: column; align-items: center; justify-content: space-between; } .profile__highlight__wrapper { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; font-size: 0.8rem; width: 100%; flex-grow: 1; } .profile__highlight { padding: 0.4rem; border-radius: 0.5rem; font-weight: 600; width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.25rem; background: var(--highlight-bg); border: 1px solid var(--border-color); } .profile__header { display: flex; justify-content: space-between; align-items: start; width: 100%; gap: 0.75rem; } .profile__name { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.25rem; } .profile__name h2 { display: flex; align-items: center; font-size: 1.5rem; gap: 0.5rem; } .profile__name p { font-size: 1.05rem; color: var(--text-bg); } .profile__avatar { flex-grow: 3; max-width: 8rem; min-width: 5rem; } .profile__avatar img { position: relative; width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 1rem; margin: 0 auto; margin-top: -50%; border: 4px solid var(--profile-bg); } .social-links { display: flex; margin: 0.5rem auto 1rem auto; width: 100%; justify-content: center; list-style-type: none; gap: 1rem; flex-wrap: wrap; } .social-links a { background: var(--socials-bg); padding: 0.5rem; border-radius: 0.5rem; display: flex; width: 3rem; height: 3rem; align-items: center; justify-content: center; gap: 0.5rem; border: 1px solid var(--border-color); color: var(--social-color); transition: all 0.3s; } .social-links a svg { width: 100%; height: 100%; } .social-links a:hover { border: 1px solid var(--active); } .social-links a:hover svg { stroke: var(--active); } .btn { background: var(--primary); color: var(--white); padding: 0.5rem 1rem; border-radius: 0.5rem; width: 100%; font-size: 1rem; font-weight: 600; min-height: 3rem; border: none; cursor: pointer; transition: all 0.3s; } .btn--primary { background: var(--primary); } .btn--primary:hover { background: var(--primary-darker); } .profile main { display: flex; flex-direction: column; gap: 1rem; width: 100%; } .tabs-wrapper { overflow-x: auto; padding-bottom: 0.25rem; } .tabs { position: relative; display: flex; gap: var(--tabs-gap); border: 1px solid var(--tabs-border); border-radius: 0.5rem; min-height: 3rem; list-style-type: none; } .tabs li { display: flex; z-index: 3; } .tabs li a { padding: 0.75rem 1rem; border-radius: var(--tab-radius); transition: all 0.3s; display: flex; align-items: center; justify-content: center; white-space: nowrap; color: var(--text); text-decoration: none; text-align: center; border: none; min-width: var(--tab-width); outline: none; } .tabs li a:hover { color: var(--active); } .tabs li a.active { color: var(--active); } .tab-content { display: none; overflow-y: auto; } .tab-content ul { list-style-type: disc; } .tab-content--active { display: flex; flex-direction: column; gap: 0.25rem; height: 12rem; padding: 0 0.25rem; font-size: 0.9rem; padding-bottom: 1rem; } #active-bg { position: absolute; width: 100%; isolation: isolate; max-width: var(--tab-width); height: 100%; bottom: 0; background: var(--tab-bg); z-index: 1; transition: 0.5s; border-radius: var(--tab-radius); } .tabs li:nth-child(1):has(.active)~#active-bg { transform: translateX(calc(0)); } .tabs li:nth-child(2):has(.active)~#active-bg { transform: translateX(calc(var(--tab-width) + var(--tabs-gap))); } .tabs li:nth-child(3):has(.active)~#active-bg { transform: translateX(calc(var(--tab-width)*2 + var(--tabs-gap)*2)); } .content-links { list-style-type: none; display: flex; flex-direction: column; margin-top: 0.5rem; gap: 0.75rem; padding: 0.5rem 0; } .content-links li a { display: flex; background: var(--socials-bg); align-items: center; gap: 0.5rem; border-radius: 0.35rem; color: var(--text); padding: 0.5rem; text-decoration: none; border: 1px solid var(--border-color); transition: all 0.3s; } .content-links li a:hover { border: 1px solid var(--active); color: var(--active); } .reviews { margin-top: 1rem; display: flex; flex-direction: column; gap: 1rem; width: 100%; } .review { display: flex; gap: 0.5rem; align-items: start; padding: 0.5rem; border-radius: 0.5rem; background: var(--highlight-bg); border: 1px solid var(--border-color); } .review img { width: 3rem; aspect-ratio: 1/1; object-fit: cover; border-radius: 50%; } </style> </head> <body> <div class="profile"> <header class="profile__header"> <div class="profile__highlight__wrapper"> <div class="profile__highlight"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-school" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M22 9l-10 -4l-10 4l10 4l10 -4v6" /> <path d="M6 10.6v5.4a6 3 0 0 0 12 0v-5.4" /> </svg> 1760 </div> Students </div> <div class="profile__avatar"> <img src="//repo.bfw.wiki/bfwrepo/image/649d3ce22371b.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_100,h_100,/quality,q_90" loading="lazy" alt="Mentor profile"> </div> <div class="profile__highlight__wrapper"> <div class="profile__highlight"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-coin" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" /> <path d="M14.8 9a2 2 0 0 0 -1.8 -1h-2a2 2 0 1 0 0 4h2a2 2 0 1 1 0 4h-2a2 2 0 0 1 -1.8 -1" /> <path d="M12 7v10" /> </svg> 149$ </div> Hourly Rate </div> </header> <div class="profile__name"> <h2>Melissa Taylor</h2> <p>Frontend/Fullstack Developer </p> </div> <ul class="social-links"> <li> <a href="#"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-github" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" /> </svg> </a> </li.........完整代码请登录后点击上方下载按钮下载查看
网友评论0