公众号 css 样式

方案一

/* Markdown 浏览器 - Solarized Light 极简统一风格 */

/* === Solarized Light 核心配色 ===
base01: #586e75  base00: #657b83  base1: #93a1a1
base2: #eee8d5  base3: #fdf6e3  orange: #cb4b16  green: #859900
*/

/* === 基础样式 === */
* {
    font-family: "lucida grande", "lucida sans unicode", lucida, helvetica, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
    font-size: 18px;
    line-height: 1.8;
    color: #657b83; /* base00 - 统一正文颜色 */
    margin: 0;
    padding: 0;
}

/* === 标题样式 === */
h1, h2, h3, h4, h5, h6 {
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, Helvetica, STKaiti, SimSun, serif;
    line-height: 1.5;
    color: #586e75; /* base01 - 统一标题颜色 */
    margin-top: 1.5em;
    margin-bottom: 0.8em;
}

h1 {
    font-size: 2.2em;
    font-weight: bold;
    border-bottom: 3px solid #93a1a1; /* base1 */
    padding: 5px;
    margin-bottom: 1.2em;
}

h2 {
    font-size: 1.8em;
    font-weight: bold;
    border-bottom: 2px solid #93a1a1; /* base1 */
    padding: 5px;
    margin-bottom: 1em;
    width: 98%;
}

h3 {
    font-size: 1.4em;
    font-weight: bold;
    border-bottom: 1px solid #93a1a1; /* base1 */
    padding: 5px;
    margin-bottom: 0.8em;
    width: 98%;
}

h4 {
    font-size: 1.2em;
    font-weight: bold;
    border-bottom: 1px solid #93a1a1; /* base1 */
    padding: 5px;
    margin-bottom: 0.6em;
    width: 98%;
}

h5 {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 0.5em;
}

h6 {
    font-size: 1em;
    font-weight: bold;
    margin-bottom: 0.4em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === 段落和文本样式 === */
p {
    margin: 1em 0;
    line-height: 1.8;
}

/* === 文本格式 - 统一颜色 === */
strong {
    font-weight: bold;
}

em {
    font-style: italic;
}

del {
    text-decoration: line-through;
}

/* === 链接样式 === */
a {
    text-decoration: none;
    border-bottom: 1px dashed #cb4b16; /* orange */
    word-wrap: break-word;
    cursor: crosshair;
    transition: all 0.3s ease;
}

a:hover {
    color: #cb4b16; /* orange */
    border-bottom: none;
}

/* === 代码样式 - 统一背景色为 #fdf6e3 === */
code {
    font-family: Inconsolata, Consolas, "DEJA VU SANS MONO", "DROID SANS MONO", Proggy, monospace;
    font-size: 0.85em;
    background-color: #fdf6e3; /* base3 - 统一背景色 */
    padding: 2px 6px;
    border-radius: 3px;
}

pre {
    font-family: Inconsolata, Consolas, "DEJA VU SANS MONO", "DROID SANS MONO", Proggy, monospace;
    font-size: 0.85em;
    line-height: 1.4;
    background-color: #fdf6e3; /* base3 - 统一背景色 */
    border: none;
    border-top: 1px solid #93a1a1; /* base1 */
    border-bottom: 1px solid #93a1a1; /* base1 */
    border-radius: 0;
    padding: 12px 15px;
    margin: 0.7em 0;
    white-space: pre;
    width: 98%;
    box-sizing: border-box;
}

pre code {
    white-space: inherit;
    color: inherit;
}

/* === 引用块样式 - 统一背景色为 #fdf6e3 === */
blockquote {
    font-size: 0.95em;
    line-height: 1.6;
    background-color: #fdf6e3; /* base3 - 统一背景色 */
    border-left: 4px solid #859900; /* green */
    border-right: 1px solid #859900; /* green */
    padding: 0.1em 0.7em;
    margin: 0.7em 0;
}

blockquote p {
    margin: 0.5em 0;
}

blockquote blockquote {
    margin: 0.8em 0;
    border-left-color: #93a1a1; /* base1 */
    border-right-color: #93a1a1;
    background-color: #fdf6e3; /* base3 - 保持统一 */
}

/* === 列表样式 === */
ul, ol {
    margin: 1em 0;
    padding: 0px 0px 0px 20px;
    list-style-position: outside;
}

ul {
    list-style-type: disc;
}

ol {
    list-style-type: decimal;
}

li {
    line-height: 1.8;
}

/* 嵌套列表样式 */
li ul, li ol {
    margin: 0;
}

/* === 任务列表样式 === */
.md-task-item {
    list-style: none;
    margin-left: 0;
}

input[type="checkbox"] {
    display: inline;
    appearance: checkbox;
    width: auto;
    height: auto;
}

/* === 表格样式 - 表头统一背景色为 #fdf6e3 === */
table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
    margin: 0.7em 0;
    background-color: #fdf6e3; /* base3 */
    border: 1px solid #93a1a1; /* base1 */
}

th, td {
    padding: 8px 12px;
    border: 1px solid #93a1a1; /* base1 */
    text-align: left;
    vertical-align: top;
}

th {
    background-color: #eee8d5; /* base2 */
    font-weight: bold;
    text-align: center;
}

tr:nth-child(even) td {
    background-color: #fdf6e3; /* base3 */
}

/* === 水平线样式 === */
hr {
    border: none;
    height: 1px;
    background-color: #93a1a1; /* base1 */
    color: #93a1a1; /* base1 */
    margin: 2em 0;
}

/* === 图片样式 === */
img {
    display: block;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0.7em;
    margin-bottom: 0.7em;
    -moz-box-shadow: 0 0 3px 0 rgba(0,0,0,0.26);
    -webkit-box-shadow: 0 0 3px 0 rgba(0,0,0,0.26);
    box-shadow: 0 0 3px 0 rgba(0,0,0,0.26);
    border-radius: 6px;
    overflow: auto;
}

/* === 特殊元素样式 - 统一背景色为 #fdf6e3 === */
mark {
    background-color: #fdf6e3; /* base3 - 统一背景色 */
    padding: 2px 4px;
    border-radius: 3px;
}

kbd {
    background-color: #fdf6e3; /* base3 - 统一背景色 */
    padding: 3px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

small {
    font-size: 0.85em;
    color: #93a1a1; /* base1 */
}

sub, sup {
    font-size: 0.75em;
}

方案二

/* Markdown 浏览器 - 微信公众号优化版 */

/* === Solarized Light 核心配色 ===
base01: #586e75  base00: #657b83  base1: #93a1a1
base2: #eee8d5  base3: #fdf6e3  orange: #cb4b16
*/

/* === 基础样式 - 优化字体系统 === */
* {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", Arial, sans-serif;
    font-size: 16px; /* 微信推荐的最佳阅读字号 */
    line-height: 1.75; /* 微信推荐的黄金行间距比例 */
    color: #595959; /* 深灰色 */
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* === 标题样式 - 优化字体系统 === */
h1, h2, h3, h4, h5, h6 {
    font-family: "Georgia", "Times New Roman", "Songti SC", "SimSun", "宋体", "serif", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", serif;
    font-weight: 600; /* 使用更现代的字重 */
    line-height: 1.4; /* 标题行间距更紧凑 */
    color: #595959; /* 深灰色 */
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    letter-spacing: -0.01em; /* 轻微的字间距调整 */
}

h1 {
    font-size: 1.75em; /* 28px,适合手机阅读的大标题 */
    font-weight: 700;
    border-bottom: 3px solid #93a1a1; /* base1 */
    padding: 5px;
    margin-bottom: 1.2em;
}

h2 {
    font-size: 1.5em; /* 24px,二级标题 */
    font-weight: 600;
    border-bottom: 2px solid #93a1a1; /* base1 */
    padding: 5px;
    margin-bottom: 1em;
    width: 98%;
}

h3 {
    font-size: 1.25em; /* 20px,三级标题 */
    font-weight: 600;
    border-bottom: 1px solid #93a1a1; /* base1 */
    padding: 5px;
    margin-bottom: 0.8em;
    width: 98%;
}

h4 {
    font-size: 1.125em; /* 18px,四级标题 */
    font-weight: 600;
    border-bottom: 1px solid #93a1a1; /* base1 */
    padding: 5px;
    margin-bottom: 0.6em;
    width: 98%;
}

h5 {
    font-size: 1.0625em; /* 17px,五级标题 */
    font-weight: 600;
    margin-bottom: 0.5em;
}

h6 {
    font-size: 1em; /* 16px,六级标题与正文同大小 */
    font-weight: 600;
    margin-bottom: 0.4em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === 段落和文本样式 - 优化字体渲染 === */
p {
    margin: 1.2em 0; /* 段落间距适中 */
    line-height: 1.75; /* 与基础样式保持一致 */
    font-weight: 400;
    text-align: justify;
    text-justify: inter-ideograph;
}

/* === 文本格式 - 优化字体权重 === */
strong {
    font-weight: 600; /* 使用更现代的字重 */
}

em {
    font-style: italic;
    font-weight: 400;
}

del {
    text-decoration: line-through;
    opacity: 0.7;
}

/* === 链接样式 === */
a {
    text-decoration: none;
    border-bottom: 1px dashed #cb4b16; /* orange */
    word-wrap: break-word;
    cursor: crosshair;
    transition: all 0.3s ease;
    font-weight: 500; /* 链接稍微加粗 */
}

a:hover {
    color: #cb4b16; /* orange */
    border-bottom: none;
}

/* === 代码样式 - 优化代码字体 === */
code {
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.75em; /* 12px,代码字号稍小便于阅读 */
    font-weight: 400;
    background-color: #fdf6e3; /* base3 - 统一背景色 */
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.05em; /* 代码字间距稍微宽一点 */
    white-space: inherit;
    color: inherit;
}

pre {
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.75em; /* 12px,代码块字号 */
    font-weight: 400;
    line-height: 1.6; /* 代码块行间距适中 */
    background-color: #fdf6e3; /* base3 - 统一背景色 */
    border: none;
    border-top: 1px solid #eee8d5; /* base2 */
    border-bottom: 1px solid #eee8d5; /* base2 */
    border-radius: 0;
    padding: 12px 15px;
    margin: 1.2em 0; /* 与段落间距保持一致 */
    white-space: pre;
    width: 98%;
    box-sizing: border-box;
    letter-spacing: 0.05em;
}

/* === 引用块样式 - 优化字体渲染 === */
blockquote {
    font-size: 0.9375em; /* 15px,引用块字号稍小 */
    font-weight: 400;
    line-height: 1.7; /* 引用块行间距 */
    background-color: #fdf6e3; /* base3 - 统一背景色 */
    border-left: 4px solid #eee8d5; /* base2 */
    border-right: 1px solid #eee8d5; /* base2 */
    padding: 0.01em 1em; /* 调整内边距 */
    margin: 1.2em 0; /* 与段落间距保持一致 */
}

/* === 列表样式 - 优化字体 === */
ul, ol {
    margin: 0.6em 0;
    padding: 0px 0px 0px 20px;
    list-style-position: outside;
}

ul {
    list-style-type: disc;
}

ol {
    list-style-type: decimal;
}

li {
    line-height: 1.75; /* 列表项行间距与正文一致 */
    margin: 0.4em 0 0.4em 0.1em; /* 列表项间距 */
    font-weight: 400;
}

/* === 任务列表样式 === */
.md-task-item {
    list-style: none;
    margin-left: 0;
}

input[type="checkbox"] {
    display: inline;
    appearance: checkbox;
    width: auto;
    height: auto;
}

/* === 表格样式 - 优化字体 === */
table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
    margin: 1.2em 0; /* 与段落间距保持一致 */
    background-color: #fdf6e3; /* base3 */
    border: 1px solid #eee8d5; /* base2 */
    font-size: 0.9375em; /* 15px,表格字号稍小便于显示 */
    font-weight: 400;
}

th, td {
    padding: 10px 12px; /* 调整单元格内边距 */
    border: 1px solid #eee8d5; /* base2 */
    text-align: left;
    vertical-align: top;
    line-height: 1.6; /* 表格内行间距 */
}

th {
    border: 1px solid #e2dcc9;
    background-color: #eee8d5; /* base2 */
    font-weight: 600; /* 表头使用加粗字体 */
    text-align: center;
}

tr:nth-child(even) td {
    background-color: #fdf6e3; /* base3 */
}

/* === 水平线样式 === */
hr {
    border: none;
    height: 1px;
    background-color: #93a1a1; /* base1 */
    color: #93a1a1; /* base1 */
    margin: 2em 0;
}

/* === 图片样式 === */
img {
    display: block;
    max-width: 90%;
    margin: 10px auto;
}

figcaption {
    /*图片描述文字*/
    margin-top: 10px;
    text-align: center;
    /*当图片水平居左时,请打开*/
    color: #93a1a1; /* base1 */
    font-size: 0.7em;
}

/* === 特殊元素样式 - 优化字体 === */
mark {
    background-color: #fdf6e3; /* base3 - 统一背景色 */
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500; /* 标记文本稍微加粗 */
}

kbd {
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
    background-color: #fdf6e3; /* base3 - 统一背景色 */
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.75em; /* 12px,键盘按键字号 */
    font-weight: 500;
    letter-spacing: 0.05em;
}

small {
    font-size: 0.875em; /* 14px,小号文本 */
    font-weight: 400;
    color: #93a1a1; /* base1 */
}

sub, sup {
    font-size: 0.75em; /* 12px,上下标字号 */
    font-weight: 400;
}