HTML&CSS:数据卡片可以这样设计

效果演示

这段 HTML 和 CSS 代码创建了一个实时温度的数据卡片。它使用了 CSS 的渐变、阴影、模糊和动画效果来增强视觉效果。(gif图片不清晰)

HTML

html 复制代码
<div class="outer">
  <div class="dot"></div>
  <div class="card">
    <div class="ray"></div>
    <div class="text">75.23℃</div>
    <div>Hum</div>
    <div class="line topl"></div>
    <div class="line leftl"></div>
    <div class="line bottoml"></div>
    <div class="line rightl"></div>
  </div>
</div>
  • outer: 外层容器,用于包含整个温度计组件。
  • dot: 模拟温度计中的水银滴。
  • card: 温度计的主体部分,显示温度读数。
  • ray: 温度计的光晕效果。
  • text: 显示温度读数,使用 CSS 渐变来创建文字颜色渐变效果。
  • line: 温度计的刻度线。

CSS

css 复制代码
.outer {
  width: 300px;
  height: 250px;
  border-radius: 10px;
  padding: 1px;
  background: radial-gradient(circle 230px at 0% 0%, #ffffff, #0c0d0d);
  position: relative;
}

.dot {
  width: 5px;
  aspect-ratio: 1;
  position: absolute;
  background-color: #fff;
  box-shadow: 0 0 10px #ffffff;
  border-radius: 100px;
  z-index: 2;
  right: 10%;
  top: 10%;
  animation: moveDot 6s linear infinite;
}

@keyframes moveDot {
  0%,
  100% {
    top: 10%;
    right: 10%;
  }
  25% {
    top: 10%;
    right: calc(100% - 35px);
  }
  50% {
    top: calc(100% - 30px);
    right: calc(100% - 35px);
  }
  75% {
    top: calc(100% - 30px);
    right: 10%;
  }
}

.card {
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  border: solid 1px #202222;
  background-size: 20px 20px;
  background: radial-gradient(circle 280px at 0% 0%, #444444, #0c0d0d);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-direction: column;
  color: #fff;
}
.ray {
  width: 220px;
  height: 45px;
  border-radius: 100px;
  position: absolute;
  background-color: #c7c7c7;
  opacity: 0.4;
  box-shadow: 0 0 50px #fff;
  filter: blur(10px);
  transform-origin: 10%;
  top: 0%;
  left: 0;
  transform: rotate(40deg);
}

.card .text {
  font-weight: bolder;
  font-size: 4rem;
  background: linear-gradient(45deg, #000000 4%, #fff, #000);
  background-clip: text;
  color: transparent;
}

.line {
  width: 100%;
  height: 1px;
  position: absolute;
  background-color: #2c2c2c;
}
.topl {
  top: 10%;
  background: linear-gradient(90deg, #888888 30%, #1d1f1f 70%);
}
.bottoml {
  bottom: 10%;
}
.leftl {
  left: 10%;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, #747474 30%, #222424 70%);
}
.rightl {
  right: 10%;
  width: 1px;
  height: 100%;
}
  • .outer: 定义了温度计外层容器的样式,包括大小、圆角、背景渐变等。
  • .dot: 定义了水银滴的样式,包括大小、位置、背景颜色、阴影和动画。
  • @keyframes moveDot: 定义了水银滴的动画,使其在温度计中移动。
  • .card: 定义了温度计主体的样式,包括大小、圆角、边框、背景渐变和布局。
  • .ray: 定义了温度计光晕的样式,包括大小、位置、背景颜色、模糊效果和旋转。
  • .text 和 .unit: 定义了温度读数的样式,使用 CSS 渐变和 background-clip: text 属性来创建文字颜色渐变效果。
  • .line: 定义了温度计刻度线的样式,包括位置和背景渐变。
相关推荐
sleeppingfrog16 小时前
zebra通过zpl语言实现中文打印(二)
javascript
lang2015092817 小时前
JSR-340 :高性能Web开发新标准
java·前端·servlet
好家伙VCC17 小时前
### WebRTC技术:实时通信的革新与实现####webRTC(Web Real-TimeComm
java·前端·python·webrtc
未来之窗软件服务18 小时前
未来之窗昭和仙君(六十五)Vue与跨地区多部门开发—东方仙盟练气
前端·javascript·vue.js·仙盟创梦ide·东方仙盟·昭和仙君
baidu_2474386118 小时前
Android ViewModel定时任务
android·开发语言·javascript
嘿起屁儿整18 小时前
面试点(网络层面)
前端·网络
VT.馒头18 小时前
【力扣】2721. 并行执行异步函数
前端·javascript·算法·leetcode·typescript
有位神秘人19 小时前
Android中Notification的使用详解
android·java·javascript
phltxy19 小时前
Vue 核心特性实战指南:指令、样式绑定、计算属性与侦听器
前端·javascript·vue.js
Byron070720 小时前
Vue 中使用 Tiptap 富文本编辑器的完整指南
前端·javascript·vue.js