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条记录,每条50px+间距 */
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;
}
/* 滚动列表:承载所有记录,实现动画滚动 */
.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;
}
/* 姓名样式 */
.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%); /* 滚动至列表高度的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();
};