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

677 lines
15 KiB
CSS

/* 移动端控件样式设计规范 - 示例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;
/* 背景色系 - 深色渐变 */
--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%);
/* 边框色系 */
--border-primary: #3d4159;
--border-secondary: #4a5073;
--border-highlight: #6366f1;
--border-accent: rgba(64, 224, 208, 0.3);
/* 文字色系 */
--text-primary: #ffffff;
--text-secondary: #b4b7c9;
--text-tertiary: #9ca3af;
--text-disabled: #6b7280;
/* 移动端触摸区域尺寸 */
--touch-target-min: 44px;
--safe-area-padding: 20px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-webkit-user-select: none;
-webkit-touch-callout: none;
-webkit-tap-highlight-color: transparent;
}
html, body {
height: 100%;
overflow-x: hidden;
-webkit-text-size-adjust: 100%;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Microsoft YaHei UI", sans-serif;
background: var(--gradient-bg);
color: var(--text-primary);
line-height: 1.6;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
touch-action: manipulation;
}
/* PWA 支持的安全区域适配 */
.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);
}
/* 动态星空背景 */
.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); }
}
/* 主容器 - 全屏布局 */
.app-container {
display: flex;
flex-direction: column;
min-height: 100vh;
position: relative;
z-index: 1;
}
/* 状态栏 */
.status-bar {
background: rgba(26, 29, 41, 0.95);
backdrop-filter: blur(20px);
padding: 8px var(--safe-area-padding);
display: flex;
justify-content: space-between;
align-items: center;
font-size: 12px;
color: var(--text-tertiary);
position: sticky;
top: 0;
z-index: 100;
}
.network-status {
display: flex;
align-items: center;
gap: 6px;
}
.connection-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--secondary-color);
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; transform: scale(1); }
50% { opacity: 0.4; transform: scale(1.3); }
}
/* 主内容区域 */
.main-content {
flex: 1;
display: flex;
flex-direction: column;
padding: var(--safe-area-padding);
justify-content: center;
align-items: center;
text-align: center;
position: relative;
}
.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: 20px;
}
/* 页签切换容器 */
.tab-container {
width: 100%;
max-width: 400px;
background: var(--bg-secondary);
border: 1px solid var(--border-primary);
border-radius: 16px;
overflow: hidden;
margin-bottom: 20px;
}
.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;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.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); }
}
/* 按钮控件 */
.btn {
min-height: var(--touch-target-min);
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
padding: 14px 24px;
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;
position: relative;
overflow: hidden;
}
/* 按钮触摸反馈效果 */
.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%;
}
.btn-primary {
background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
color: #ffffff;
box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}
.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);
}
.btn-success {
background: linear-gradient(135deg, var(--secondary-color), var(--secondary-light));
color: #1a1a2e;
box-shadow: 0 4px 16px rgba(64, 224, 208, 0.3);
}
.btn-success:hover, .btn-success:focus {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(64, 224, 208, 0.4);
}
.btn-secondary {
background: rgba(99, 102, 241, 0.15);
color: var(--primary-color);
border: 1px solid var(--primary-color);
backdrop-filter: blur(10px);
}
.btn-secondary:hover, .btn-secondary:focus {
background: rgba(99, 102, 241, 0.25);
transform: translateY(-1px);
}
/* 按钮组 */
.action-buttons {
width: 100%;
max-width: 300px;
display: flex;
flex-direction: column;
gap: 16px;
margin-top: 20px;
}
/* 卡片控件 */
.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);
margin-bottom: 20px;
}
.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;
text-align: left;
}
.card-footer {
margin-top: 16px;
padding-top: 12px;
border-top: 1px solid var(--border-primary);
display: flex;
justify-content: flex-end;
gap: 12px;
}
/* 统计卡片 */
.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);
width: 100%;
max-width: 400px;
}
.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);
}
/* 列表控件 */
.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);
margin-bottom: 20px;
}
.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;
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.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;
text-align: left;
}
.list-item-subtitle {
font-size: 14px;
color: var(--text-secondary);
margin-top: 4px;
text-align: left;
}
.list-item-value {
font-size: 16px;
color: var(--secondary-color);
font-weight: 600;
}
/* 历史记录列表 */
.history-list {
max-height: 200px;
overflow-y: auto;
background: rgba(15, 52, 96, 0.4);
border-radius: 12px;
padding: 12px;
width: 100%;
max-width: 400px;
}
.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;
text-align: left;
}
.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;
}
/* 网格控件 */
.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);
max-width: 400px;
}
.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);
}
}
/* 状态指示器 */
.network-status-indicator {
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-indicator.offline {
background: var(--danger-color);
animation: networkPulse 2s infinite;
}
@keyframes networkPulse {
0%, 100% { opacity: 0.8; }
50% { opacity: 0.3; }
}
.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);
}
/* 触摸反馈 */
.haptic-feedback {
animation: hapticVibrate 0.1s ease-out;
}
@keyframes hapticVibrate {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-2px); }
75% { transform: translateX(2px); }
}
/* 响应式设计增强 */
@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;
}
.page-title {
margin-bottom: 10px;
}
.card {
margin: 10px 0;
padding: 16px;
}
}
/* 高对比度支持 */
@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);
}
}