Files
DFJ/01_文档/原型设计/移动端控件样式设计规范.md
2025-09-10 18:13:28 +08:00

963 lines
24 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 移动端控件样式设计规范
## 1. 设计理念
### 1.1 核心原则
- **移动优先**:专为手机端设计,确保在小屏幕上的最佳体验
- **避免滚动**:页面内容尽量在一屏内展示,过长内容使用页签切换
- **深色主题**:采用深色背景,减少视觉疲劳,增强科技感
- **高对比度**:确保文字和控件在各种环境下清晰可见
### 1.2 视觉风格
- **科技感**:使用渐变色彩和毛玻璃效果,营造现代科技氛围
- **简洁明了**:控件设计简洁,功能明确,避免复杂装饰
- **一致性**:所有页面和控件保持统一的设计语言
## 2. 色彩系统
### 2.1 主色调
```css
:root {
/* 主色调 - 深空科技蓝 */
--primary-color: #6366f1;
--primary-light: #8b5cf6;
--primary-dark: #4f46e5;
/* 辅助色 - 科技青色 */
--secondary-color: #40e0d0;
--secondary-light: #26d0ce;
/* 强调色 - 橙色 */
--accent-color: #f59e0b;
--accent-light: #fbbf24;
/* 危险色 - 红色 */
--danger-color: #ff4757;
--danger-light: #ff6b6b;
}
```
### 2.2 背景色系
```css
:root {
/* 背景色系 - 深色渐变 */
--bg-primary: #0f1419;
--bg-secondary: #1a1d29;
--bg-tertiary: #252837;
--bg-elevated: #2d3142;
/* 渐变背景 */
--gradient-bg: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 30%, #16213e 70%, #0f3460 100%);
}
```
### 2.3 边框色系
```css
:root {
/* 边框色系 */
--border-primary: #3d4159;
--border-secondary: #4a5073;
--border-highlight: #6366f1;
--border-accent: rgba(64, 224, 208, 0.3);
}
```
### 2.4 文字色系
```css
:root {
/* 文字色系 */
--text-primary: #ffffff;
--text-secondary: #b4b7c9;
--text-tertiary: #9ca3af;
--text-disabled: #6b7280;
}
```
## 3. 布局原则
### 3.1 安全区域适配
```css
.safe-area {
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
padding-top: env(safe-area-inset-top);
padding-bottom: env(safe-area-inset-bottom);
}
```
### 3.2 触摸目标尺寸
```css
:root {
--touch-target-min: 44px;
--safe-area-padding: 20px;
}
```
### 3.3 页签切换设计
当内容过长时,使用页签切换替代滚动:
```html
<div class="tab-container">
<div class="tab-header">
<div class="tab-item active" data-tab="tab1">标签1</div>
<div class="tab-item" data-tab="tab2">标签2</div>
<div class="tab-item" data-tab="tab3">标签3</div>
</div>
<div class="tab-content">
<div class="tab-pane active" id="tab1">内容1</div>
<div class="tab-pane" id="tab2">内容2</div>
<div class="tab-pane" id="tab3">内容3</div>
</div>
</div>
<style>
.tab-container {
width: 100%;
max-width: 400px;
background: var(--bg-secondary);
border-radius: 16px;
overflow: hidden;
}
.tab-header {
display: flex;
background: var(--bg-tertiary);
border-bottom: 1px solid var(--border-primary);
}
.tab-item {
flex: 1;
padding: 12px;
text-align: center;
font-size: 14px;
color: var(--text-secondary);
cursor: pointer;
transition: all 0.3s ease;
}
.tab-item.active {
color: var(--primary-color);
background: var(--bg-secondary);
border-bottom: 2px solid var(--primary-color);
}
.tab-content {
padding: 20px;
max-height: 400px;
overflow-y: auto;
}
.tab-pane {
display: none;
}
.tab-pane.active {
display: block;
animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
</style>
```
## 4. 控件样式规范
### 4.1 按钮控件
#### 4.1.1 主要按钮
```css
.btn-primary {
min-height: var(--touch-target-min);
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
padding: 14px 24px;
background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
color: #ffffff;
box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.btn-primary:hover, .btn-primary:focus {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}
.btn-primary:active {
transform: translateY(0);
box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}
```
#### 4.1.2 成功按钮
```css
.btn-success {
min-height: var(--touch-target-min);
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
padding: 14px 24px;
background: linear-gradient(135deg, var(--secondary-color), var(--secondary-light));
color: #1a1a2e;
box-shadow: 0 4px 16px rgba(64, 224, 208, 0.3);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.btn-success:hover, .btn-success:focus {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(64, 224, 208, 0.4);
}
```
#### 4.1.3 次要按钮
```css
.btn-secondary {
min-height: var(--touch-target-min);
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
padding: 14px 24px;
background: rgba(99, 102, 241, 0.15);
color: var(--primary-color);
border: 1px solid var(--primary-color);
backdrop-filter: blur(10px);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.btn-secondary:hover, .btn-secondary:focus {
background: rgba(99, 102, 241, 0.25);
transform: translateY(-1px);
}
```
### 4.2 卡片控件
#### 4.2.1 基础卡片
```css
.card {
width: 100%;
max-width: 400px;
background: rgba(22, 33, 62, 0.8);
border: 1px solid rgba(64, 224, 208, 0.3);
border-radius: 16px;
padding: 20px;
backdrop-filter: blur(10px);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid var(--border-primary);
}
.card-title {
font-size: 18px;
font-weight: 600;
color: var(--text-primary);
}
.card-subtitle {
font-size: 14px;
color: var(--text-secondary);
}
.card-body {
color: var(--text-secondary);
font-size: 14px;
line-height: 1.6;
}
.card-footer {
margin-top: 16px;
padding-top: 12px;
border-top: 1px solid var(--border-primary);
display: flex;
justify-content: flex-end;
gap: 12px;
}
```
#### 4.2.2 统计卡片
```css
.stats-card {
background: rgba(22, 33, 62, 0.8);
border: 1px solid rgba(64, 224, 208, 0.3);
border-radius: 12px;
padding: 16px;
text-align: center;
backdrop-filter: blur(8px);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.stats-title {
font-size: 12px;
color: rgba(255, 255, 255, 0.6);
margin-bottom: 8px;
}
.stats-value {
font-size: 20px;
font-weight: bold;
color: var(--secondary-color);
text-shadow: 0 0 10px rgba(64, 224, 208, 0.3);
}
```
### 4.3 列表控件
#### 4.3.1 基础列表
```css
.list-container {
width: 100%;
max-width: 400px;
background: rgba(22, 33, 62, 0.8);
border: 1px solid rgba(64, 224, 208, 0.3);
border-radius: 16px;
overflow: hidden;
backdrop-filter: blur(10px);
}
.list-item {
padding: 16px;
border-bottom: 1px solid rgba(64, 224, 208, 0.1);
display: flex;
align-items: center;
justify-content: space-between;
transition: all 0.3s ease;
}
.list-item:last-child {
border-bottom: none;
}
.list-item:active {
background: rgba(64, 224, 208, 0.1);
transform: scale(0.98);
}
.list-item-title {
font-size: 16px;
color: var(--text-primary);
font-weight: 500;
}
.list-item-subtitle {
font-size: 14px;
color: var(--text-secondary);
margin-top: 4px;
}
.list-item-value {
font-size: 16px;
color: var(--secondary-color);
font-weight: 600;
}
```
#### 4.3.2 历史记录列表
```css
.history-list {
max-height: 200px;
overflow-y: auto;
background: rgba(15, 52, 96, 0.4);
border-radius: 12px;
padding: 12px;
}
.history-item {
font-size: 13px;
color: rgba(255, 255, 255, 0.8);
margin-bottom: 8px;
padding: 8px;
background: rgba(64, 224, 208, 0.1);
border-radius: 8px;
border-left: 3px solid var(--secondary-color);
transition: all 0.3s ease;
}
.history-item:last-child {
margin-bottom: 0;
}
.history-item.hit {
border-left-color: var(--danger-color);
background: rgba(255, 71, 87, 0.1);
}
.history-item.miss {
border-left-color: var(--text-tertiary);
background: rgba(108, 117, 125, 0.1);
}
.history-item.destroy {
border-left-color: var(--accent-color);
background: rgba(245, 158, 11, 0.2);
font-weight: 600;
}
```
### 4.4 网格控件
#### 4.4.1 游戏网格
```css
.game-grid {
width: 100%;
aspect-ratio: 1;
background: rgba(15, 52, 96, 0.6);
border: 2px solid rgba(64, 224, 208, 0.5);
border-radius: 12px;
padding: 6px;
backdrop-filter: blur(8px);
position: relative;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.grid-container {
width: 100%;
height: 100%;
display: grid;
grid-template-columns: repeat(10, 1fr);
grid-template-rows: repeat(10, 1fr);
gap: 1px;
background: rgba(64, 224, 208, 0.1);
border-radius: 8px;
overflow: hidden;
}
.grid-cell {
background: rgba(15, 52, 96, 0.8);
border: 1px solid rgba(64, 224, 208, 0.15);
display: flex;
align-items: center;
justify-content: center;
font-size: 10px;
color: rgba(255, 255, 255, 0.4);
transition: all 0.2s ease;
position: relative;
min-height: 30px;
font-weight: 600;
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.grid-cell:active {
background: rgba(64, 224, 208, 0.4);
transform: scale(0.95);
border-color: var(--secondary-color);
}
.grid-cell.hit {
background: linear-gradient(135deg, var(--danger-color) 0%, var(--danger-light) 100%);
color: white;
animation: hitFlash 0.6s ease-out;
box-shadow: 0 0 15px var(--danger-color);
}
.grid-cell.miss {
background: rgba(108, 117, 125, 0.6);
color: var(--text-tertiary);
}
@keyframes hitFlash {
0% {
transform: scale(1);
box-shadow: 0 0 10px var(--danger-color);
}
50% {
transform: scale(1.1);
box-shadow: 0 0 20px var(--danger-color);
}
100% {
transform: scale(1);
box-shadow: 0 0 5px var(--danger-color);
}
}
```
### 4.5 状态指示器
#### 4.5.1 网络状态
```css
.network-status {
position: fixed;
top: calc(15px + env(safe-area-inset-top));
right: 15px;
width: 12px;
height: 12px;
border-radius: 50%;
background: var(--secondary-color);
z-index: 101;
opacity: 0.8;
}
.network-status.offline {
background: var(--danger-color);
animation: networkPulse 2s infinite;
}
@keyframes networkPulse {
0%, 100% { opacity: 0.8; }
50% { opacity: 0.3; }
}
```
#### 4.5.2 回合指示器
```css
.turn-indicator {
position: fixed;
top: calc(70px + env(safe-area-inset-top));
left: 50%;
transform: translateX(-50%);
padding: 8px 20px;
border-radius: 20px;
font-size: 14px;
font-weight: 600;
z-index: 99;
backdrop-filter: blur(10px);
transition: all 0.3s ease;
}
.turn-indicator.my-turn {
background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-light) 100%);
color: #1a1a2e;
box-shadow: 0 4px 20px rgba(64, 224, 208, 0.4);
}
.turn-indicator.opponent-turn {
background: linear-gradient(135deg, rgba(255, 71, 87, 0.9) 0%, rgba(255, 56, 56, 0.9) 100%);
color: white;
border: 1px solid rgba(255, 71, 87, 0.6);
box-shadow: 0 4px 20px rgba(255, 71, 87, 0.3);
}
```
## 5. 动画效果
### 5.1 背景动画
```css
/* 动态星空背景 */
.star-field {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
overflow: hidden;
}
.star {
position: absolute;
background: rgba(64, 224, 208, 0.8);
border-radius: 50%;
animation: twinkle 3s infinite;
}
@keyframes twinkle {
0%, 100% { opacity: 0.3; transform: scale(1); }
50% { opacity: 1; transform: scale(1.2); }
}
```
### 5.2 按钮触摸反馈
```css
.btn::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
background: rgba(255, 255, 255, 0.3);
border-radius: 50%;
transform: translate(-50%, -50%);
transition: width 0.3s, height 0.3s;
}
.btn:active::before {
width: 100%;
height: 100%;
}
```
### 5.3 页面切换动画
```css
.page-transition-enter {
opacity: 0;
transform: translateX(100%);
}
.page-transition-enter-active {
opacity: 1;
transform: translateX(0);
transition: all 0.3s ease-out;
}
.page-transition-exit {
opacity: 1;
transform: translateX(0);
}
.page-transition-exit-active {
opacity: 0;
transform: translateX(-100%);
transition: all 0.3s ease-in;
}
```
## 6. 移动端适配
### 6.1 响应式断点
```css
/* 小屏幕手机 */
@media (max-width: 375px) {
.btn {
font-size: 15px;
min-height: 42px;
padding: 12px 20px;
}
.grid-cell {
font-size: 8px;
min-height: 28px;
}
.stats-value {
font-size: 16px;
}
}
/* 短屏幕手机 */
@media (max-height: 640px) {
.main-content {
justify-content: flex-start;
padding-top: 20px;
}
.game-header {
margin-bottom: 20px;
}
.card {
margin: 15px 0;
padding: 16px;
}
}
/* 横屏模式 */
@media (orientation: landscape) and (max-height: 500px) {
.game-container {
top: calc(70px + env(safe-area-inset-top));
}
.turn-indicator {
top: calc(40px + env(safe-area-inset-top));
}
.boards-container {
flex-direction: row;
max-width: 90%;
gap: 15px;
}
.board-section {
flex: 1;
}
}
```
### 6.2 触摸优化
```css
/* 防止双指缩放和滚动 */
body {
touch-action: manipulation;
-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;
}
/* 触摸反馈 */
.haptic-feedback {
animation: hapticVibrate 0.1s ease-out;
}
@keyframes hapticVibrate {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-2px); }
75% { transform: translateX(2px); }
}
/* 防止长按菜单 */
* {
-webkit-touch-callout: none;
-webkit-tap-highlight-color: transparent;
}
```
### 6.3 无障碍支持
```css
/* 高对比度支持 */
@media (prefers-contrast: high) {
:root {
--text-primary: #ffffff;
--text-secondary: #e5e5e5;
--border-primary: #ffffff;
--bg-secondary: #000000;
}
}
/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
/* 暗色模式强制支持 */
@media (prefers-color-scheme: dark) {
body {
background: var(--bg-primary);
color: var(--text-primary);
}
}
```
## 7. 实现示例
### 7.1 完整页面示例
```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>移动端页面示例</title>
<style>
/* 引入上述所有CSS变量和基础样式 */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Microsoft YaHei UI", sans-serif;
background: var(--gradient-bg);
color: var(--text-primary);
min-height: 100vh;
display: flex;
flex-direction: column;
overflow-x: hidden;
}
.app-container {
flex: 1;
display: flex;
flex-direction: column;
padding: var(--safe-area-padding);
max-width: 100%;
margin: 0 auto;
}
.status-bar {
background: rgba(26, 29, 41, 0.95);
backdrop-filter: blur(20px);
padding: 8px 0;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 12px;
color: var(--text-tertiary);
margin-bottom: 20px;
}
.main-content {
flex: 1;
display: flex;
flex-direction: column;
gap: 20px;
align-items: center;
}
.page-title {
font-size: 24px;
font-weight: 700;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin-bottom: 10px;
}
.tab-container {
width: 100%;
max-width: 400px;
}
.action-buttons {
width: 100%;
max-width: 300px;
display: flex;
flex-direction: column;
gap: 16px;
margin-top: 20px;
}
</style>
</head>
<body class="safe-area">
<div class="app-container">
<div class="status-bar">
<div class="network-status">
<div class="connection-dot"></div>
<span>在线</span>
</div>
<div class="app-version">v1.0.0</div>
</div>
<main class="main-content">
<h1 class="page-title">页面标题</h1>
<div class="tab-container">
<div class="tab-header">
<div class="tab-item active" data-tab="tab1">标签1</div>
<div class="tab-item" data-tab="tab2">标签2</div>
<div class="tab-item" data-tab="tab3">标签3</div>
</div>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<div class="card">
<div class="card-header">
<h3 class="card-title">卡片标题</h3>
<span class="card-subtitle">副标题</span>
</div>
<div class="card-body">
<p>这是卡片内容区域,可以放置各种信息。</p>
</div>
<div class="card-footer">
<button class="btn btn-secondary">取消</button>
<button class="btn btn-primary">确定</button>
</div>
</div>
</div>
<div class="tab-pane" id="tab2">
<div class="stats-card">
<div class="stats-title">统计项</div>
<div class="stats-value">100</div>
</div>
</div>
<div class="tab-pane" id="tab3">
<div class="list-container">
<div class="list-item">
<div>
<div class="list-item-title">列表项1</div>
<div class="list-item-subtitle">描述信息</div>
</div>
<div class="list-item-value">值1</div>
</div>
<div class="list-item">
<div>
<div class="list-item-title">列表项2</div>
<div class="list-item-subtitle">描述信息</div>
</div>
<div class="list-item-value">值2</div>
</div>
</div>
</div>
</div>
</div>
<div class="action-buttons">
<button class="btn btn-primary">主要操作</button>
<button class="btn btn-secondary">次要操作</button>
</div>
</main>
</div>
<script>
// 页签切换功能
document.querySelectorAll('.tab-item').forEach(tab => {
tab.addEventListener('click', () => {
const tabId = tab.dataset.tab;
// 更新标签状态
document.querySelectorAll('.tab-item').forEach(t => t.classList.remove('active'));
tab.classList.add('active');
// 更新内容显示
document.querySelectorAll('.tab-pane').forEach(pane => pane.classList.remove('active'));
document.getElementById(tabId).classList.add('active');
});
});
// 触觉反馈
document.querySelectorAll('.btn, .list-item, .tab-item').forEach(element => {
element.addEventListener('click', () => {
if ('vibrate' in navigator) {
navigator.vibrate(10);
}
document.body.classList.add('haptic-feedback');
setTimeout(() => document.body.classList.remove('haptic-feedback'), 100);
});
});
</script>
</body>
</html>
```
## 8. 微信小程序适配建议
### 8.1 样式转换
- 将CSS变量转换为微信小程序的theme.json或全局样式
- 使用rpx单位替代px确保在不同屏幕尺寸下的适配
- 将backdrop-filter等不支持的效果替换为半透明背景
### 8.2 组件转换
- 将HTML控件转换为微信小程序的自定义组件
- 使用微信小程序的动画API替代CSS动画
- 利用微信小程序的页面生命周期管理状态
### 8.3 性能优化
- 使用微信小程序的虚拟列表处理长列表
- 优化图片资源,使用微信小程序的图片压缩
- 合理使用setData避免频繁更新页面数据
## 9. 总结
本设计规范基于提供的两个HTML文件的设计风格总结了一套适用于手机端微信小程序的控件样式设计规范。主要特点包括
1. **深色科技主题**:使用深色背景和渐变色彩,营造现代科技感
2. **移动优先**:专为手机端设计,考虑触摸操作和屏幕尺寸限制
3. **避免滚动**:通过页签切换等方式减少页面滚动
4. **统一视觉语言**:所有控件保持一致的设计风格
5. **丰富的交互反馈**:提供视觉、触觉等多种反馈方式
6. **良好的无障碍支持**:考虑高对比度、减少动画等特殊需求
通过遵循本设计规范,可以创建出用户体验良好、视觉一致的移动端应用界面。