10条提现记录(显示3条·循环滚动)
/* 全局样式重置,消除默认边距 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* 页面居中布局,美化背景 */
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f5f7fa;
font-family: "Microsoft YaHei", sans-serif;
}
/* 提现容器:限定高度,仅显示3条记录,隐藏超出部分 */
.withdraw-container {
width: 380px;
height: 180px; /* 刚好容纳3条记录,适配单条记录高度 */
background-color: #ffffff;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
padding: 20px;
overflow: hidden; /* 隐藏可视区域外的记录 */
position: relative;
}
/* 容器标题样式 */
.container-title {
font-size: 18px;
font-weight: 600;
color: #333333;
margin-bottom: 16px;
text-align: center;
border-bottom: 1px solid #eeeeee;
padding-bottom: 12px;
}
/* 滚动列表:承载所有10条记录,实现动画滚动 */
.withdraw-list {
position: absolute;
top: 70px;
left: 20px;
right: 20px;
animation: scroll-up 15s linear infinite; /* 15秒匀速滚动,无限循环 */
}
/* 单个提现记录:固定高度,保证布局整齐 */
.withdraw-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 0;
border-bottom: 1px dashed #f0f0f0;
font-size: 14px;
height: 50px; /* 单条记录固定高度,确保3条填满可视区域 */
}
/* 姓名样式:灰色常规显示 */
.user-name {
color: #666666;
font-weight: 400;
}
/* 金额样式:红色突出,更醒目 */
.withdraw-amount {
color: #e63946;
font-weight: 500;
}
/* 鼠标悬浮暂停滚动,方便查看详情 */
.withdraw-container:hover .withdraw-list {
animation-play-state: paused;
}
/* 核心动画:向上无缝循环滚动 */
@keyframes scroll-up {
0% {
transform: translateY(0); /* 初始位置(顶部) */
}
100% {
transform: translateY(-100%); /* 滚动至列表底部,实现循环 */
}
}
// 1. 常见姓氏和名字单字,保证姓名更贴合实际
const familyNames = ['赵', '钱', '孙', '李', '周', '吴', '郑', '王', '冯', '陈'];
const givenNames = ['伟', '华', '明', '强', '丽', '静', '文', '杰', '军', '涛', '万', '芳'];
// 2. 生成隐藏中间字的姓名(格式:姓+*+名,如李*万)
function generateHiddenName() {
const randomFamily = familyNames[Math.floor(Math.random() * familyNames.length)];
const randomGiven = givenNames[Math.floor(Math.random() * givenNames.length)];
return `${randomFamily}*${randomGiven}`;
}
// 3. 生成100-2000元之间的随机整数金额(带"元"单位)
function generateRandomAmount() {
const randomAmount = Math.floor(Math.random() * 1901) + 100;
return `${randomAmount}元`;
}
// 4. 渲染10条提现记录到页面
function renderWithdrawRecords() {
const listContainer = document.getElementById('withdrawList');
let recordsHtml = '';
// 循环生成10条记录
for (let i = 0; i < 10; i++) {
const userName = generateHiddenName();
const userAmount = generateRandomAmount();
// 拼接单条记录的HTML结构
recordsHtml += `
提现姓名:${userName}
金额:${userAmount}
`;
}
// 关键:复制一份记录,实现无缝循环滚动(无末尾空白断层)
listContainer.innerHTML = recordsHtml + recordsHtml;
}
// 5. 页面加载完成后自动渲染记录
window.onload = function() {
renderWithdrawRecords();
};