/* PDF分页优化样式 */ /* 表格不断行:整个表格保持在同一页 */ table { page-break-inside: avoid; break-inside: avoid; } /* 图片前不分页:图片与前面的标题保持在同一页 */ h2, h3, h4 { page-break-after: avoid; break-after: avoid; } /* 图片本身不分页 */ img { page-break-inside: avoid; break-inside: avoid; page-break-before: avoid; break-before: avoid; } /* 图片前的标题与图片保持在一起 */ h2 + img, h3 + img, h4 + img, p + img { page-break-before: avoid; break-before: avoid; } /* 基础排版优化 */ body { font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; font-size: 14px; line-height: 1.8; color: #1e293b; max-width: 900px; margin: 0 auto; padding: 20px; } h1 { font-size: 24px; border-bottom: 2px solid #312e81; padding-bottom: 10px; } h2 { font-size: 20px; color: #312e81; margin-top: 30px; } h3 { font-size: 17px; color: #4338ca; margin-top: 20px; } h4 { font-size: 15px; color: #6366f1; } table { border-collapse: collapse; width: 100%; margin: 12px 0; } th, td { border: 1px solid #cbd5e1; padding: 8px 12px; text-align: left; } th { background: #f1f5f9; font-weight: 600; } tr:nth-child(even) { background: #f8fafc; } blockquote { border-left: 4px solid #818cf8; padding-left: 16px; color: #475569; margin: 12px 0; } code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 13px; } img { max-width: 100%; height: auto; display: block; margin: 16px auto; }