/* 跨平台兼容样式文件 */ /* ==================== 基础重置 ==================== */ * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } html, body { width: 100%; height: 100%; overflow-x: hidden; -webkit-overflow-scrolling: touch; } /* ==================== 平台检测 ==================== */ /* H5平台 */ /* #ifdef H5 */ page { background-color: #f5f7fa; } /* #endif */ /* App平台 */ /* #ifdef APP-PLUS */ page { background-color: #f5f7fa; padding-top: var(--status-bar-height, 0px); } /* #endif */ /* 微信小程序 */ /* #ifdef MP-WEIXIN */ page { background-color: #f5f7fa; } /* #endif */ /* ==================== 像素比处理 ==================== */ /* 高像素比设备(Retina屏幕) */ @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { .border-1px { position: relative; } .border-1px::after { content: ''; position: absolute; top: 0; left: 0; width: 200%; height: 200%; border: 1px solid var(--border-color, #e0e0e0); transform: scale(0.5); transform-origin: 0 0; pointer-events: none; } } /* 超高像素比设备 */ @media (-webkit-min-device-pixel-ratio: 3), (min-resolution: 288dpi) { .border-1px::after { width: 300%; height: 300%; transform: scale(0.333); } } /* ==================== 字体优化 ==================== */ /* 修复移动端字体模糊 */ .text-blur-fix { -webkit-transform: translateZ(0); transform: translateZ(0); backface-visibility: hidden; -webkit-backface-visibility: hidden; } /* 字体大小适配 */ .font-size-adaptive { font-size: calc(16px + (20 - 16) * ((100vw - 320px) / (750 - 320))); } @media (min-width: 750px) { .font-size-adaptive { font-size: 20px; } } @media (max-width: 320px) { .font-size-adaptive { font-size: 16px; } } /* ==================== 布局兼容 ==================== */ /* Flex布局兼容 */ .flex { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; } .flex-center { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center; } .flex-between { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-box-pack: justify; -webkit-justify-content: space-between; -ms-flex-pack: justify; justify-content: space-between; } .flex-column { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; } /* Grid布局兼容 */ .grid { display: -ms-grid; display: grid; } /* ==================== 滚动优化 ==================== */ /* 修复移动端滚动 */ .scroll-fix { -webkit-overflow-scrolling: touch; overflow-y: auto; overflow-x: hidden; } /* 隐藏滚动条但保留功能 */ .scrollbar-hide::-webkit-scrollbar { display: none; } .scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; } /* ==================== 点击优化 ==================== */ /* 修复移动端点击延迟 */ .fast-click { touch-action: manipulation; -webkit-tap-highlight-color: transparent; } /* 点击反馈 */ .clickable { cursor: pointer; transition: opacity 0.2s ease; } .clickable:active { opacity: 0.7; } /* ==================== 图片优化 ==================== */ /* 图片自适应 */ .img-responsive { max-width: 100%; height: auto; display: block; } /* 图片懒加载占位 */ .img-placeholder { background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size: 200% 100%; animation: placeholder-loading 1.5s infinite; } @keyframes placeholder-loading { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } } /* ==================== 文本优化 ==================== */ /* 文本省略 */ .text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .text-ellipsis-2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; text-overflow: ellipsis; } .text-ellipsis-3 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; text-overflow: ellipsis; } /* ==================== 安全区域 ==================== */ /* 刘海屏适配 */ .safe-area-top { padding-top: constant(safe-area-inset-top); padding-top: env(safe-area-inset-top); } .safe-area-bottom { padding-bottom: constant(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom); } .safe-area-left { padding-left: constant(safe-area-inset-left); padding-left: env(safe-area-inset-left); } .safe-area-right { padding-right: constant(safe-area-inset-right); padding-right: env(safe-area-inset-right); } .safe-area-all { padding: constant(safe-area-inset-top) constant(safe-area-inset-right) constant(safe-area-inset-bottom) constant(safe-area-inset-left); padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); } /* 横屏适配 */ @media screen and (orientation: landscape) { .safe-area-bottom { padding-bottom: constant(safe-area-inset-left); padding-bottom: env(safe-area-inset-left); } .safe-area-top { padding-top: constant(safe-area-inset-right); padding-top: env(safe-area-inset-right); } } /* ==================== 平台特定样式 ==================== */ /* H5平台特定样式 */ /* #ifdef H5 */ .h5-only { display: block; } @media (hover: hover) { .hover-effect:hover { opacity: 0.8; cursor: pointer; } } /* #endif */ /* App平台特定样式 */ /* #ifdef APP-PLUS */ .app-only { display: block; } /* 状态栏高度适配 */ .status-bar-height { height: var(--status-bar-height, 20px); } /* #endif */ /* 微信小程序特定样式 */ /* #ifdef MP-WEIXIN */ .mp-weixin-only { display: block; } /* #endif */ /* ==================== 响应式断点优化 ==================== */ /* 超小屏设备 */ @media screen and (max-width: 320px) { .container { padding: 10px; } .grid-item { width: 50%; } } /* 小屏设备 */ @media screen and (min-width: 321px) and (max-width: 375px) { .container { padding: 12px; } .grid-item { width: 33.33%; } } /* 中等屏设备 */ @media screen and (min-width: 376px) and (max-width: 414px) { .container { padding: 14px; } .grid-item { width: 25%; } } /* 大屏设备 */ @media screen and (min-width: 415px) and (max-width: 768px) { .container { padding: 16px; } .grid-item { width: 20%; } } /* 超大屏设备 */ @media screen and (min-width: 769px) { .container { padding: 20px; max-width: 1200px; margin: 0 auto; } .grid-item { width: 16.66%; } } /* ==================== 动画优化 ==================== */ /* 硬件加速 */ .hardware-accelerate { -webkit-transform: translateZ(0); transform: translateZ(0); -webkit-backface-visibility: hidden; backface-visibility: hidden; -webkit-perspective: 1000; perspective: 1000; } /* 平滑过渡 */ .smooth-transition { -webkit-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); } /* ==================== 工具类 ==================== */ /* 清除浮动 */ .clearfix::after { content: ''; display: table; clear: both; } /* 居中 */ .center { margin-left: auto; margin-right: auto; } /* 隐藏元素 */ .hidden { display: none !important; } /* 可见性 */ .invisible { visibility: hidden; } /* 绝对定位 */ .absolute { position: absolute; } /* 相对定位 */ .relative { position: relative; } /* 固定定位 */ .fixed { position: fixed; } /* 层级 */ .z-1 { z-index: 1; } .z-10 { z-index: 10; } .z-100 { z-index: 100; } .z-1000 { z-index: 1000; }