u
This commit is contained in:
1 parent
4d60582d4f
commit
2fb19021ae
40 files changed
+2552
-348
No files matched your search
+100
-147
@@ -1,165 +1,118 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="zh">
|
||||
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>个人中心</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>金额输入 Demo</title>
|
||||
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto;
|
||||
}
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI";
|
||||
background: #f5f6f7;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #f5f6f8;
|
||||
}
|
||||
.container {
|
||||
max-width: 420px;
|
||||
margin: 0 auto;
|
||||
background: #fff;
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 420px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.amount-wrapper {
|
||||
text-align: center;
|
||||
padding: 30px 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ===== Header ===== */
|
||||
.header {
|
||||
height: 180px;
|
||||
padding: 20px;
|
||||
background: linear-gradient(135deg, #4f8cff, #6ed0ff);
|
||||
color: #fff;
|
||||
position: relative;
|
||||
}
|
||||
.amount-label {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.user {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 40px;
|
||||
}
|
||||
.amount {
|
||||
font-size: 42px;
|
||||
font-weight: 600;
|
||||
color: #111;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
.info {
|
||||
margin-left: 14px;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 13px;
|
||||
opacity: 0.9;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* ===== Card ===== */
|
||||
.card {
|
||||
background: #fff;
|
||||
margin: -40px 16px 16px;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin: 16px;
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ===== Item ===== */
|
||||
.item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px;
|
||||
font-size: 15px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.item span {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
/* Danger */
|
||||
.danger {
|
||||
color: #ff4d4f;
|
||||
}
|
||||
</style>
|
||||
/* 点击反馈 */
|
||||
.amount-wrapper:active {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
/* 隐藏输入 */
|
||||
.hidden-input {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
```
|
||||
<!-- Header -->
|
||||
<div class="header">
|
||||
<div class="user">
|
||||
<div class="avatar"></div>
|
||||
<div class="info">
|
||||
<div class="name">张三</div>
|
||||
<div class="desc">让工具更高效 ⚡</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
|
||||
<!-- 功能区 -->
|
||||
<div class="card">
|
||||
<div class="item">
|
||||
<span>我的工具</span>
|
||||
<span class="arrow">›</span>
|
||||
</div>
|
||||
<div class="item">
|
||||
<span>数据管理</span>
|
||||
<span class="arrow">›</span>
|
||||
</div>
|
||||
<div class="item">
|
||||
<span>云同步</span>
|
||||
<span class="arrow">›</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 金额 -->
|
||||
<div class="amount-wrapper" onclick="focusInput()">
|
||||
<div class="amount-label">金额</div>
|
||||
<div class="amount" id="amount">¥ 0.00</div>
|
||||
</div>
|
||||
|
||||
<!-- 设置区 -->
|
||||
<div class="section">
|
||||
<div class="item">
|
||||
<span>深色模式</span>
|
||||
<span class="arrow">›</span>
|
||||
</div>
|
||||
<div class="item">
|
||||
<span>通知设置</span>
|
||||
<span class="arrow">›</span>
|
||||
</div>
|
||||
<div class="item">
|
||||
<span>关于应用</span>
|
||||
<span class="arrow">›</span>
|
||||
</div>
|
||||
<div class="item">
|
||||
<span class="danger">退出登录</span>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
<!-- 隐藏输入 -->
|
||||
<input
|
||||
id="input"
|
||||
class="hidden-input"
|
||||
type="text"
|
||||
inputmode="decimal"
|
||||
oninput="handleInput(this.value)"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let value = "0";
|
||||
|
||||
function focusInput() {
|
||||
document.getElementById("input").focus();
|
||||
}
|
||||
|
||||
function handleInput(text) {
|
||||
// 只保留数字和小数点
|
||||
let v = text.replace(/[^\d.]/g, "");
|
||||
|
||||
// 只允许一个 .
|
||||
const parts = v.split(".");
|
||||
if (parts.length > 2) {
|
||||
v = parts[0] + "." + parts[1];
|
||||
}
|
||||
|
||||
// 限制两位小数
|
||||
if (v.includes(".")) {
|
||||
let [int, dec] = v.split(".");
|
||||
v = int + "." + dec.slice(0, 2);
|
||||
}
|
||||
|
||||
// 去前导0
|
||||
if (v.startsWith("0") && v[1] !== ".") {
|
||||
v = v.replace(/^0+/, "");
|
||||
}
|
||||
|
||||
if (v === "") v = "0";
|
||||
|
||||
value = v;
|
||||
updateUI();
|
||||
}
|
||||
|
||||
function updateUI() {
|
||||
document.getElementById("amount").innerText = "¥ " + value;
|
||||
document.getElementById("input").value = value;
|
||||
}
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user