UI 1.1
样式不变,合并重复的媒体查询
优化了选择器的效率
整理代码结构,使其更清晰
确保响应式规则的一致性
/* ================= 核心变量系统优化 ================= */
:root {
/* 字体栈优化 */
--font-cn: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
--font-code: "JetBrains Mono", "Consolas", "Monaco", "Cascadia Code", monospace;
/* 颜色系统优化 */
--color-text-dark: #e0e0e0;
--color-bg-dark: #1a1a1a;
--border-dark: rgba(255, 255, 255, 0.15);
/* 动画时长标准化 */
--transition-fast: 0.2s;
--transition-normal: 0.3s;
--transition-slow: 0.5s;
}
/* ================= 基础布局系统优化 ================= */
.container {
max-width: 100%;
width: 100%;
margin: 0 auto;
padding: 0 20px;
box-sizing: border-box;
}
/* ================= 字体与排版系统优化 ================= */
/* 基础文本样式 */
body,
.Post-body,
.DiscussionListItem-title {
font-family: var(--font-cn);
font-size: 16px;
line-height: 1.7;
letter-spacing: 0.03em;
text-align: justify;
}
/* 段落优化 */
.Post-body p {
margin: 1.2em 0;
max-width: none;
}
/* 标题层级优化 */
.DiscussionPage-nav .item-title {
font-size: 22px;
letter-spacing: 0.08em;
font-weight: 500;
line-height: 1.3;
}
/* ================= 组件样式系统优化 ================= */
/* 引用块组件 */
.Post-quote {
background: #ee729d;
border-left: 4px solid #e9ecef;
padding: 1rem;
border-radius: 4px;
transition: transform var(--transition-fast) ease-in-out;
margin: 1rem 0;
}
.Post-quote:focus-within,
.Post-quote:hover {
transform: translateX(2px);
}
/* 代码块组件 */
pre, code {
font-family: var(--font-code);
font-size: 0.9em;
}
pre {
overflow-x: auto;
padding: 1rem;
border-radius: 6px;
background: rgba(0, 0, 0, 0.05);
}
/* ================= 动画效果系统优化 ================= */
/* 彩虹按钮动画 */
.IndexPage-newDiscussion {
background: linear-gradient(124deg,
#ff2400, #e81d1d, #e8b71d, #e3e81d,
#1de840, #1ddde8, #2b1de8, #dd00f3);
background-size: 400% 400%;
animation: rainbow 20s ease infinite;
}
@keyframes rainbow {
0%, 100% { background-position: 0% 82%; }
50% { background-position: 100% 19%; }
}
/* 标题浮动动画 */
.Hero-title {
display: inline-block;
margin: 0 5px;
animation: gentleFloat 6s ease-in-out infinite;
transform: translateZ(0); /* 硬件加速 */
}
@keyframes gentleFloat {
0%, 100% { transform: translateY(0) rotate(0); }
33% { transform: translateY(-8px) rotate(1deg); }
66% { transform: translateY(4px) rotate(-0.5deg); }
}
/* 背景流动动画 */
.Hero.WelcomeHero {
background-image:
linear-gradient(45deg,
transparent 9%, rgba(255, 182, 193, 0.6) 9%, rgba(255, 182, 193, 0.6) 51%,
transparent 51%, transparent 57%, rgba(255, 204, 204, 0.6) 57%
),
linear-gradient(-45deg,
transparent 12%, rgba(255, 228, 225, 0.6) 12%, rgba(255, 228, 225, 0.6) 33%,
rgba(255, 192, 203, 0.6) 33%, rgba(255, 192, 203, 0.6) 45%, transparent 45%
),
linear-gradient(90deg, #fff, #fff);
background-size: 200% 200%;
animation: bgFlow 40s linear infinite;
}
@keyframes bgFlow {
0% { background-position: 0% 0%; }
100% { background-position: 200% 200%; }
}
/* ================= 暗黑模式系统优化 ================= */
/* 属性选择器暗黑模式 */
[data-theme="dark"] {
color-scheme: dark;
--color-text: var(--color-text-dark);
--color-bg: var(--color-bg-dark);
}
[data-theme="dark"] body {
background: var(--color-bg-dark);
color: var(--color-text-dark);
}
[data-theme="dark"] .item-welcomeBox {
display: none !important;
}
[data-theme="dark"] .DiscussionHero--colored {
color: var(--color-text-dark) !important;
opacity: 0.95;
}
[data-theme="dark"] .Post-quote {
background: rgba(255, 255, 255, 0.09);
border-color: var(--border-dark);
color: #cfd8dc;
}
[data-theme="dark"] .Composer-body textarea {
background: rgba(255, 255, 255, 0.08);
border-color: var(--border-dark);
color: inherit;
}
/* 系统级暗黑模式支持 */
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
color-scheme: dark;
--color-text: var(--color-text-dark);
--color-bg: var(--color-bg-dark);
}
:root:not([data-theme="light"]) body {
background: var(--color-bg-dark);
color: var(--color-text-dark);
}
:root:not([data-theme="light"]) .item-welcomeBox {
display: none !important;
}
}
/* ================= 响应式布局系统优化 ================= */
/* 大屏设备 (1200px以下) */
@media (max-width: 1200px) {
.container {
padding: 0 15px;
}
}
/* 平板设备 (768px以下) */
@media (max-width: 768px) {
body,
.Post-body,
.DiscussionListItem-title {
font-size: 15px;
line-height: 1.6;
text-align: left;
}
.DiscussionPage-nav .item-title {
font-size: 18px;
letter-spacing: 0.05em;
}
}
/* 移动设备 (767px以下) */
@media (max-width: 767px) {
.PostUser-level {
display: none;
}
/* 移动端动画优化 */
.Hero-title {
animation: none;
transform: translateZ(0);
}
.DiscussionListItem:hover {
transform: none;
box-shadow: none;
}
/* 移动端字体优化 */
body,
.Post-body,
.DiscussionListItem-title {
font-size: 15px;
line-height: 1.6;
text-align: left;
letter-spacing: 0.02em;
}
.Post-body p {
margin: 1em 0;
}
/* 移动端按钮性能优化 */
.IndexPage-newDiscussion {
background-size: 200% 200%;
animation-duration: 10s;
}
}
/* ================= 可访问性与性能优化 ================= */
/* 减少动画偏好支持 */
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
.Hero-title,
.IndexPage-newDiscussion,
.Hero.WelcomeHero {
animation: none !important;
}
.Post-quote {
transition: none !important;
}
}
/* 焦点可见性优化 */
.IndexPage-newDiscussion:focus-visible {
outline: 2px solid #4dabf7;
outline-offset: 2px;
border-radius: 4px;
}
/* 高对比度模式支持 */
@media (prefers-contrast: high) {
.Post-quote {
border-width: 2px;
background: transparent;
}
.IndexPage-newDiscussion {
background: #0066cc !important;
animation: none !important;
}
}
/* 打印样式优化 */
@media print {
.Hero-title,
.IndexPage-newDiscussion {
animation: none !important;
}
.Hero.WelcomeHero {
background: white !important;
animation: none !important;
}
/* 打印时隐藏不必要的元素 */
.item-welcomeBox,
.IndexPage-newDiscussion {
display: none !important;
}
}