AI 生成: 一个简洁美观的网页计算器,支持加、减、乘、除和清除功能,使用纯 HTML/CSS/JavaScript 实现。
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
/* ===== 全局重置 ===== */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #1e1e2f 0%, #2d2d44 100%);
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* ===== 计算器容器 ===== */
|
||||
.calculator {
|
||||
width: 100%;
|
||||
max-width: 360px;
|
||||
background: #2a2a3d;
|
||||
border-radius: 20px;
|
||||
padding: 24px;
|
||||
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
/* ===== 显示区域 ===== */
|
||||
.display {
|
||||
background: #1b1b2a;
|
||||
color: #f5f5f5;
|
||||
font-size: 2.4rem;
|
||||
font-weight: 300;
|
||||
text-align: right;
|
||||
padding: 20px 18px;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 20px;
|
||||
min-height: 80px;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
overflow: hidden;
|
||||
box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
/* ===== 按键网格 ===== */
|
||||
.keys {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* ===== 按键基础样式 ===== */
|
||||
.key {
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
font-size: 1.4rem;
|
||||
font-weight: 500;
|
||||
color: #eaeaea;
|
||||
background: #3a3a52;
|
||||
border-radius: 12px;
|
||||
padding: 18px 0;
|
||||
transition: transform 0.08s ease, background 0.2s ease, box-shadow 0.2s ease;
|
||||
user-select: none;
|
||||
box-shadow: 0 4px 0 #26263a;
|
||||
}
|
||||
|
||||
.key:hover {
|
||||
background: #45456a;
|
||||
}
|
||||
|
||||
.key:active {
|
||||
transform: translateY(2px);
|
||||
box-shadow: 0 2px 0 #26263a;
|
||||
}
|
||||
|
||||
/* ===== 运算符按钮 ===== */
|
||||
.key-op {
|
||||
background: #4a4a78;
|
||||
color: #ffd166;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 4px 0 #2e2e4d;
|
||||
}
|
||||
|
||||
.key-op:hover {
|
||||
background: #5a5a92;
|
||||
}
|
||||
|
||||
/* ===== 清除按钮 ===== */
|
||||
.key-clear {
|
||||
background: #e63946;
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 4px 0 #a8232e;
|
||||
}
|
||||
|
||||
.key-clear:hover {
|
||||
background: #ff4d5a;
|
||||
}
|
||||
|
||||
/* ===== 等号按钮(跨两行) ===== */
|
||||
.key-equals {
|
||||
grid-row: span 2;
|
||||
background: linear-gradient(180deg, #06d6a0, #04b184);
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
font-size: 1.6rem;
|
||||
box-shadow: 0 4px 0 #028a66;
|
||||
}
|
||||
|
||||
.key-equals:hover {
|
||||
background: linear-gradient(180deg, #0be0aa, #05c492);
|
||||
}
|
||||
|
||||
/* ===== 0 按钮跨两列 ===== */
|
||||
.key-zero {
|
||||
grid-column: span 2;
|
||||
}
|
||||
|
||||
/* ===== 响应式 ===== */
|
||||
@media (max-width: 400px) {
|
||||
.display {
|
||||
font-size: 1.9rem;
|
||||
padding: 16px 14px;
|
||||
}
|
||||
.key {
|
||||
font-size: 1.2rem;
|
||||
padding: 15px 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user