当前位置: 首页 > news >正文

【组件】翻牌器效果

目录

  • 效果
  • 组件代码
  • 背景素材

效果

在这里插入图片描述

组件代码

<template><divclass="card-flop":style="{height: typeof height === 'number' ? `${height}px` : height,'--box-width': typeof boxWidth === 'number' ? `${boxWidth}px` : boxWidth,'--box-height': typeof boxHeight === 'number' ? `${boxHeight}px` : boxHeight,'--color': color}"><div:class="{ 'card-flop__number': true, 'is-comma': isNotNumber(number) }"v-for="(number, index) in countArray":key="`num-${index}`"><div v-if="isNotNumber(number)" class="card-flop__number-comma"><span>{{ number }}</span></div><div v-else class="card-flop__number-box" :style="{ transform: getTransform(number, index) }"><div v-for="(item, index) in numbers" class="card-flop__number-item" :key="`item-${index}`"><span>{{ item }}</span></div></div></div><div class="card-flop__unit"><span>{{ unit }}</span></div></div>
</template><script >
export default {name: 'CardFlopCom',components: {},props: {count: {type: [String, Number],default: 0},height: {type: Number,default: 32},boxWidth: {type: Number,default: 24},boxHeight: {type: Number,default: 32},unit: {type: String,default: '条'},color: {type: String,default: '#fff'}},data() {return {numbers: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}},computed: {countArray() {// 将数字转换为带千位分隔符的字符串const formattedNumber = Number(this.count).toLocaleString()// 分割成数组,包括逗号return formattedNumber.split('')}},methods: {isNotNumber(number) {return [',', '.'].includes(number)},getTransform(number) {const offset = Number(number) * this.boxHeightreturn `translateY(-${offset}px)`}}
}
</script><style lang="scss" scoped>
.card-flop {display: flex;align-items: baseline;justify-content: center;&__number {height: var(--box-height);color: var(--color);background-size: 100% 100%;background-repeat: no-repeat;margin-right: 3px;overflow: hidden;&:not(.is-comma) {width: var(--box-width);// background-image: url('@/assets/images/screen-zhidu/card_flop_bg.png');background-image: url('~@/assets/images/screen-zhidu/card_flop_bg.png');}&.is-comma {margin-right: 2px;}&-box {transition: transform 1s ease-in-out;}&-item {width: var(--box-width);height: var(--box-height);display: flex;align-items: center;justify-content: center;span {font-weight: bold;font-size: 26px;}}}&__unit {font-size: 16px;color: rgba(225, 239, 255, 0.6);margin-left: 2px;}
}
</style>

背景素材

在这里插入图片描述

相关文章:

  • CSS3实现的账号密码输入框提示效果
  • [CSS3]vw/vh移动适配
  • Hadoop复习(一)
  • AWS WebRTC:获取ICE服务地址(part 1)
  • 2025.05.28【Choropleth】群体进化学专用图:区域数据可视化
  • day023-面试题总结
  • 中企出海大会|打造全球化云计算一张网,云网络助力中企出海和AI创新
  • 智能手表怎么申请欧盟EN 18031认证
  • Building Android Kernels with Bazel
  • Eclipse 插件开发 5.2 编辑器 获取当前编辑器
  • 1.2 掌握CSS样式表
  • style scoped作用域
  • MySQL8.4主从复制
  • Android 云手机横屏模式下真机键盘遮挡输入框问题处理
  • pycharm生成图片
  • 力扣-找到字符串中所有字母异位符
  • 力扣面试150题--二叉树的最近公共祖先
  • JWT安全:假密钥.【签名随便写实现越权绕过.】
  • 动态规划-LCR 091.粉刷房子-力扣(LeetCode)
  • Vim文本编辑器快捷键用法以及简单介绍
  • 江宁做网站/推广是做什么工作的
  • 做创业项目的网站/百度应用商店官网
  • 网站建设中的色彩搭配/短视频推广平台
  • 国内免费工厂网站建设/如何检测网站是否安全
  • dw网站模板/今日重大财经新闻
  • 服务器维护要多久/seo推广服务哪家好