/* 定义全局 CSS 变量,默认亮色主题 */
:root {
--background-color: #f5f5f5; /* 页面背景 */
--main-bg-color: #fff; /* 主内容背景 */
--menu-bg-color: #fff; /* 菜单背景 */
--text-color: #3d3a33; /* 文字颜色 */
--link-color: #0066cc; /* 链接颜色(亮色主题,蓝色) */
--link-hover-color: #003366; /* 链接悬停颜色(亮色主题) */
--menu-title-bg: url('https://images.unsplash.com/photo-1518531933037-91b2f5f229cc');
--menu-title-border: #736e60;
--menu-title-text: #ffffff;
--title-gradient: linear-gradient(135deg, #17ead9, #6078ea);
--code-bg-gradient: linear-gradient(135deg, #000000, #434343);
--code-text-color: #ff9b04;
--child-links-gradient: linear-gradient(135deg, #fad7a1, #e96d71);
--child-links-hover-bg: rgba(255, 255, 255, 0.2);
--child-links-hover-text: #ffffff;
--shadow-color: rgba(165, 170, 168, 0.253);
}
/* 深色主题 */
@media (prefers-color-scheme: dark) {
:root {
--background-color: #1e2729;
--main-bg-color: #2d3436;
--menu-bg-color: #2d3436;
--text-color: #dfe6e9;
--link-color: #a3e7fc; /* 深色主题,链接颜色变浅 */
--link-hover-color: #76d7ea;
--menu-title-bg: url('https://images.unsplash.com/photo-1518531933037-91b2f5f229cc');
--menu-title-border: #aaaaaa;
--menu-title-text: #dfe6e9;
--title-gradient: linear-gradient(135deg, #0a9c8f, #3a4e8a);
--code-bg-gradient: linear-gradient(135deg, #1a1a1a, #2a2a2a);
--code-text-color: #ffcc00;
--child-links-gradient: linear-gradient(135deg, #d4a05e, #a33e42);
--child-links-hover-bg: rgba(255, 255, 255, 0.1);
--child-links-hover-text: #dfe6e9;
--shadow-color: rgba(0, 0, 0, 0.5);
}
}
/* 全局 body 样式 */
body {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
background: var(--background-color);
margin: 0;
}
/* 全局链接样式 */
a {
text-decoration: none;
color: var(--link-color);
}
a:hover {
color: var(--link-hover-color);
text-decoration: underline;
}
/* 移除列表默认样式 */
ul li {
list-style-type: none;
padding-left: 0;
margin-left: 0;
}
/* 布局容器 */
#layout {
align-items: flex-start;
}
/* 主内容区域 */
#main {
margin: 25px 10px;
background-color: var(--main-bg-color);
border-radius: 20px;
box-shadow: 0 0 10px 5px var(--shadow-color);
color: var(--text-color);
padding: 20px;
}
/* 页面标题 */
#title {
padding: 5px 20px;
background: var(--title-gradient);
border-radius: 10px;
color: var(--text-color);
}
/* 父链接 */
#parentLink {
margin-right: 20px;
font-weight: bold;
}
#parentLink a {
padding-left: 10px;
color: var(--menu-title-text);
}
/* 导航菜单 */
#menu {
position: sticky;
top: 25px;
margin: 25px 10px;
padding: 10px;
border-radius: 20px;
box-shadow: 0 0 10px 5px var(--shadow-color);
overflow-y: auto;
max-height: calc(100vh - 50px);
background-color: var(--menu-bg-color);
color: var(--text-color);
-webkit-overflow-scrolling: touch;
scrollbar-width: none;
-ms-overflow-style: none;
}
#menu::-webkit-scrollbar {
display: none;
}
#menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
filter: blur(0px);
z-index: -1;
}
#menu > p:first-child {
padding: 5px 20px;
border-bottom: 2px solid var(--menu-title-border);
border-radius: 10px;
color: var(--menu-title-text);
background: var(--menu-title-bg);
}
#menu > p:first-child a {
color: var(--menu-title-text);
}
/* CKEditor 内容样式修复 */
.ck-content,
#content {
color: var(--text-color);
}
/*
1. 字体相关
color:文字颜色,例如 color: #ff0000;(红色)。
font-size:字体大小,例如 font-size: 24px; 或 font-size: 1.5em;。
font-weight:字体粗细,例如 font-weight: bold; 或 font-weight: 700;。
font-family:字体,例如 font-family: "Arial", sans-serif;。
text-align:文本对齐,例如 text-align: center;。
text-decoration:文本装饰,例如 text-decoration: underline;(但不适合长下划线效果,建议用伪元素)。
2. 布局相关属性
margin:外边距,例如 margin: 1em 0 0.5em 0;(上、右、下、左)。
padding:内边距,例如 padding-bottom: 5px;。
display:显示方式,例如 display: inline-block;(常用于伪元素定位)。
position:定位方式,例如 position: relative;(为下划线伪元素做准备)。
3. 语法
逗号的作用是将多个选择器组合在一起,告诉 CSS:“这些选择器都应用下面的样式{}块”。
*/
/* CKEditor 标题样式 */
.ck-content h2,
#content h2 {
position: relative;
display: block; /* block占满容器宽度, inline-block基于文字宽度*/
}
.ck-content h2::after,
#content h2::after {
content: "";
position: absolute;
left: 0;
bottom: -5px;
width: 100%; /* 下划线长度 */
height: 4px; /* 下划线粗细 */
background-color: #0087ca; /* 下划线颜色 */
}
.ck-content h3,
#content h3 {
position: relative;
display: block; /* block占满容器宽度, inline-block基于文字宽度*/
}
.ck-content h3::after,
#content h3::after {
content: "";
position: absolute;
left: 0;
bottom: -4px;
width: 100%; /* 下划线长度 */
height: 0.5px; /* 下划线粗细 */
background-color: #aba9a9; /* 下划线颜色 */
}
.ck-content h1,
.ck-content h4,
.ck-content h5,
.ck-content h6,
#content h1,
#content h4,
#content h5,
#content h6 {
color: var(--text-color);
margin: 0.5em 0;
}
/* CKEditor 段落样式 */
.ck-content p,
#content p {
margin: 1em 0;
line-height: 1.6;
}
/* CKEditor 列表样式 */
/* 定义 CKEditor 和 #content 区域内顶级(单级)列表的基本样式 */
.ck-content ul,
.ck-content ol,
#content ul,
#content ol {
margin: 0.4em 0; /* 上下外边距,1em 表示 1 倍当前字体大小(通常约 16px),用于与上下文分隔 */
/* 单位:em(相对字体大小)、px(像素)、rem(根字体大小)、%(百分比)等 */
/* 示例值:0, 0.5em, 10px, 1rem */
padding-left: 40px; /* 左侧内边距,40px 表示固定 40 像素,用于列表符号或编号的缩进 */
/* 单位:px(像素)、em、rem、% 等 */
/* 示例值:20px, 2em, 30px */
}
/* 所有列表项的通用样式 */
/* 针对 .ck-content 和 #content 内所有列表项(li),包括单级和多级 */
.ck-content li,
#content li {
list-style-type: inherit; /* 列表符号类型,inherit 表示继承父级的值(如 disc 或 decimal) */
/* 枚举值:disc(圆点)、circle(空心圆)、square(方块)、decimal(数字)、none(无)等 */
/* 默认:ul 为 disc,ol 为 decimal */
margin:0.4em 0; /* 外边距,0 表示移除默认外边距,避免与 padding 叠加 */
padding: 0.1em 0; /* 内边距,1px 0 表示上下 1 像素、左右 0 像素,控制列表项之间的垂直间距 */
/* 单位:px、em、rem、% 等 */
/* 示例值:2px 0, 0.2em 0, 5px 5px */
line-height: 1.2; /* 行高,1.2 表示 1.2 倍字体大小,使列表紧凑且易读 */
/* 单位:无单位(倍数)、px、em、% 等 */
/* 示例值:1, 1.5, 20px, 120% */
}
/* 多级列表调整 */
/* 针对 .ck-content 和 #content 内嵌套列表(二级及以上)的样式优化 */
.ck-content ul ul,
.ck-content ol ul,
#content ul ul,
#content ol ul {
margin: 0.4em 0; /* 上下外边距,减少嵌套时的间距 */
padding-left: 40px;
}
/* CKEditor 代码块样式 */
.ck-content pre,
#content pre {
background: var(--code-bg-gradient);
color: var(--code-text-color);
border-radius: 10px;
font-family: 'Consolas', monospace;
padding: 10px;
overflow-x: auto;
}
/* CKEditor 内联代码样式 */
.ck-content code,
#content code {
background: var(--code-bg-gradient);
color: var(--code-text-color);
padding: 2px 5px;
border-radius: 5px;
font-family: 'Consolas', monospace;
}
/* CKEditor 图片样式修复 */
.ck-content img,
#content img {
max-width: 100%; /* 限制宽度不超过容器 */
height: auto; /* 保持原始宽高比例 */
display: block; /* 避免内联元素导致的间距问题 */
margin: 10px 0; /* 添加上下间距 */
}
/* 子链接样式 */
#childLinks ul li {
margin: 5px 10px;
padding: 0px 8px;
border-radius: 10px;
background: var(--child-links-gradient);
}
#childLinks.grid ul li a {
border: none;
display: block;
padding: 8px;
}
#childLinks.grid ul li a:hover {
color: var(--child-links-hover-text);
background-color: var(--child-links-hover-bg);
text-decoration: underline;
}
/* 移动端适配 */
@media (max-width: 48em) {
#main {
width: 100%;
margin: 10px 0;
border-radius: 0; /* 小屏幕下移除圆角 */
}
.ck-content img,
#content img {
width: 100%; /* 小屏幕下强制宽度占满 */
height: auto; /* 保持比例 */
}
}