Răsfoiți Sursa

fix: 尝试修复pdf题目跨页问题

过卫栋 5 zile în urmă
părinte
comite
dfbbc7224c
1 a modificat fișierele cu 64 adăugiri și 5 ștergeri
  1. 64 5
      resources/views/pdf/exam-paper.blade.php

+ 64 - 5
resources/views/pdf/exam-paper.blade.php

@@ -87,14 +87,31 @@
             align-items: center;
             justify-content: center;
         }
-        .section-title { font-size: 16px; font-weight: bold; margin-top: 20px; margin-bottom: 10px; }
-        .question { margin-bottom: 15px; page-break-inside: avoid; }
+        /* 大题标题:不与后面内容分开 */
+        .section-title {
+            font-size: 16px;
+            font-weight: bold;
+            margin-top: 20px;
+            margin-bottom: 10px;
+            page-break-after: avoid;
+            break-after: avoid;
+        }
+        /* 题目整体:不分页 */
+        .question {
+            margin-bottom: 15px;
+            page-break-inside: avoid;
+            break-inside: avoid;
+            -webkit-column-break-inside: avoid;
+        }
+        /* 题目网格:不分页 */
         .question-grid {
             display: grid;
             grid-template-columns: auto 1fr;
             column-gap: 4px;
             row-gap: 6px;
             align-items: flex-start;
+            page-break-inside: avoid;
+            break-inside: avoid;
         }
         .question-lead {
             display: flex;
@@ -118,24 +135,55 @@
             margin: 0 0 4px 0;
             white-space: nowrap;
         }
-        .question-stem { display: inline-block; font-size: 14px; font-family: inherit; }
-        .question-content { font-size: 14px; margin-bottom: 8px; line-height: 1.6; }
-        .options { display: grid; row-gap: 8px; margin-top: 8px; }
+        /* 题目内容:防止孤行 */
+        .question-stem {
+            display: inline-block;
+            font-size: 14px;
+            font-family: inherit;
+            orphans: 3;
+            widows: 3;
+        }
+        .question-content {
+            font-size: 14px;
+            margin-bottom: 8px;
+            line-height: 1.6;
+            orphans: 3;
+            widows: 3;
+        }
+        .question-main {
+            orphans: 3;
+            widows: 3;
+        }
+        /* 选项容器:不分页 */
+        .options {
+            display: grid;
+            row-gap: 8px;
+            margin-top: 8px;
+            page-break-inside: avoid;
+            break-inside: avoid;
+        }
         .options-grid-4 {
             display: grid;
             grid-template-columns: repeat(4, 1fr);
             gap: 8px 12px;
+            page-break-inside: avoid;
+            break-inside: avoid;
         }
         .options-grid-2 {
             display: grid;
             grid-template-columns: 1fr 1fr;
             gap: 8px 20px;
+            page-break-inside: avoid;
+            break-inside: avoid;
         }
         .options-grid-1 {
             display: grid;
             grid-template-columns: 1fr;
             gap: 8px;
+            page-break-inside: avoid;
+            break-inside: avoid;
         }
+        /* 单个选项:不分页 */
         .option {
             width: 100%;
             font-size: 14px;
@@ -143,15 +191,20 @@
             word-wrap: break-word;
             display: flex;
             align-items: flex-start;
+            page-break-inside: avoid;
+            break-inside: avoid;
         }
         .option strong { margin-right: 4px; }
         .option-inline { display: inline-flex; align-items: baseline; margin-right: 20px; }
         .option-compact { font-size: 14px; line-height: 1.6; }
+        /* 答案元信息:不分页 */
         .answer-meta {
             font-size: 12px;
             color: #2f2f2f;
             line-height: 1.75;
             margin-top: 4px;
+            page-break-inside: avoid;
+            break-inside: avoid;
         }
         .answer-line + .answer-line { margin-top: 4px; }
         .solution-step {
@@ -162,9 +215,12 @@
         .step-label { white-space: nowrap; }
         .solution-heading { font-weight: 700; }
         .solution-content { display: inline-block; line-height: 1.75; }
+        /* 解析区域:不分页 */
         .solution-section {
             margin-top: 8px;
             padding: 6px 8px;
+            page-break-inside: avoid;
+            break-inside: avoid;
         }
         .solution-section strong {
             font-size: 13px;
@@ -184,9 +240,12 @@
             border: 1px dashed #eee;
             margin-top: 10px;
         }
+        /* 答案区域:不分页 */
         .answer-area {
             position: relative;
             margin-top: 12px;
+            page-break-inside: avoid;
+            break-inside: avoid;
         }
         .answer-area .answer-label {
             position: absolute;