关注用户信息卡片

效果展示

CSS 知识点

  • box-shadow 属性回顾
  • CSS 变量回顾

实现页面整体布局

html 复制代码
<div class="card">
  <div class="box">
    <!-- 视频 -->
    <div class="vide_box">
      <video src="user.mp4" type="video/mp4" autoplay loop muted></video>
    </div>
  </div>
  <div class="box">
    <!-- 用户基本信息 -->
    <div class="content">
      <h2>
        cat miao
        <br />
        <span>Professional Artist</span>
      </h2>
      <ul>
        <li>文章<span>62</span></li>
        <li>关注<span>122</span></li>
        <li>点赞<span>32</span></li>
      </ul>
      <button>关注</button>
    </div>
  </div>
  <!-- 用户头像 -->
  <div class="circle">
    <div class="img_box">
      <img src="user.jpg" />
    </div>
  </div>
</div>

实现页面整体样式

css 复制代码
.card {
  position: relative;
  width: 320px;
  height: 430px;
  display: flex;
  flex-flow: column wrap;
  justify-content: space-between;
}

.card .box {
  position: relative;
  width: 110%;
  height: 200px;
  border-radius: 15px;
}

/* 实现卡片四周的圆角 */
.card .box:nth-child(1)::before {
  content: "";
  position: absolute;
  top: 108px;
  left: -1px;
  width: 20px;
  height: 20px;
  background: transparent;
  z-index: 10;
  border-bottom-left-radius: 18px;
  box-shadow: -6px 6px var(--clr);
}

.card .box:nth-child(1)::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 115px;
  width: 20px;
  height: 20px;
  background: transparent;
  z-index: 10;
  border-bottom-left-radius: 18px;
  box-shadow: -6px 6px var(--clr);
}

.card .box:nth-child(2)::before {
  content: "";
  position: absolute;
  top: 92px;
  left: -1px;
  width: 20px;
  height: 20px;
  background: transparent;
  z-index: 10;
  border-top-left-radius: 16px;
  box-shadow: -8px -8px var(--clr);
}

.card .box:nth-child(2)::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 120px;
  width: 20px;
  height: 20px;
  background: transparent;
  z-index: 10;
  border-top-left-radius: 16px;
  box-shadow: -8px -8px var(--clr);
}

完成用户头像和视频部分样式

css 复制代码
.card .circle .img_box,
.card .box .vide_box {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 50%;
}

.card .box .vide_box {
  border-radius: 15px;
}

.card .circle .img_box img,
.card .box .vide_box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

完成用户基本数据部分样式

这里只是展示部分代码。

css 复制代码
.card .box .content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 30px 10px 20px;
  align-items: center;
}

.card .box .content h2 {
  width: 100%;
  padding-left: 120px;
  text-transform: uppercase;
  font-size: 1.15em;
  letter-spacing: 0.1em;
  font-weight: 600;
  line-height: 1.1em;
  color: #333;
}

.card .box .content ul {
  position: relative;
  top: 15px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  padding: 0 10px;
  justify-content: space-evenly;
}

.card .box .content ul li {
  list-style: none;
  display: flex;
  flex-direction: column;
  text-align: center;
  padding: 0 10px;
  font-size: 0.85em;
  font-weight: 500;
  color: #999;
}

.card .box .content ul li:not(:last-child) {
  border-right: 1px solid #ccc;
}

实现关注按钮样式

css 复制代码
.card .box .content button {
  position: relative;
  top: 40px;
  padding: 8px 30px;
  border: none;
  outline: none;
  background: #03a9f4;
  border-radius: 30px;
  color: #fff;
  font-size: 1em;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  border: 5px solid var(--clr);
  box-shadow: 0 0 0 10px #fff;
  transition: 0.5s;
}

.card .box .content button:hover {
  letter-spacing: 0.5em;
  background: #ff3d7f;
}

.card .box .content button::before {
  content: "";
  position: absolute;
  top: 17px;
  left: -31px;
  width: 20px;
  height: 20px;
  background: transparent;
  border-top-right-radius: 24px;
  box-shadow: 5px -7px #fff;
}

.card .box .content button::after {
  content: "";
  position: absolute;
  top: 16px;
  right: -32px;
  width: 20px;
  height: 20px;
  background: transparent;
  border-top-left-radius: 24px;
  box-shadow: -5px -7px #fff;
}

完整代码下载

完整代码下载

相关推荐
2501_915918411 小时前
Web 前端可视化开发工具对比 低代码平台、可视化搭建工具、前端可视化编辑器与在线可视化开发环境的实战分析
前端·低代码·ios·小程序·uni-app·编辑器·iphone
程序员的世界你不懂2 小时前
【Flask】测试平台开发,新增说明书编写和展示功能 第二十三篇
java·前端·数据库
索迪迈科技2 小时前
网络请求库——Axios库深度解析
前端·网络·vue.js·北京百思可瑞教育·百思可瑞教育
gnip2 小时前
JavaScript二叉树相关概念
前端
rannn_1112 小时前
【Javaweb学习|实训总结|Week1】html基础,CSS(选择器、常用样式、盒子模型、弹性盒布局、CSS定位、动画),js(基本类型、运算符典例)
css·笔记·学习·html
attitude.x3 小时前
PyTorch 动态图的灵活性与实用技巧
前端·人工智能·深度学习
β添砖java3 小时前
CSS3核心技术
前端·css·css3
空山新雨(大队长)3 小时前
HTML第八课:HTML4和HTML5的区别
前端·html·html5
猫头虎-前端技术4 小时前
浏览器兼容性问题全解:CSS 前缀、Grid/Flex 布局兼容方案与跨浏览器调试技巧
前端·css·node.js·bootstrap·ecmascript·css3·媒体