Prechádzať zdrojové kódy

fix: 答题页也处理跨页问题

过卫栋 6 dní pred
rodič
commit
ca071cbf64
1 zmenil súbory, kde vykonal 71 pridanie a 7 odobranie
  1. 71 7
      resources/views/pdf/exam-grading.blade.php

+ 71 - 7
resources/views/pdf/exam-grading.blade.php

@@ -52,14 +52,31 @@
             padding: 0 12px;
         }
         .header { text-align: center; margin-bottom: 1.5rem; border-bottom: 2px solid #000; padding-bottom: 1rem; }
-        .section-title { font-size: 16px; font-weight: bold; margin-top: 16px; margin-bottom: 10px; }
-        .question { margin-bottom: 14px; page-break-inside: avoid; }
+        /* 大题标题:不与后面内容分开 */
+        .section-title {
+            font-size: 16px;
+            font-weight: bold;
+            margin-top: 16px;
+            margin-bottom: 10px;
+            page-break-after: avoid;
+            break-after: avoid;
+        }
+        /* 题目整体:不分页 */
+        .question {
+            margin-bottom: 14px;
+            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;
@@ -74,29 +91,70 @@
         .question-number { white-space: nowrap; margin-right: 2px; }
         .grading-boxes { gap: 4px; flex-wrap: wrap; align-items: center; }
         .grading-boxes span { vertical-align: middle; }
-        .question-main { font-size: 14px; line-height: 1.65; font-family: inherit; display: block; }
+        /* 题目内容:防止孤行 */
+        .question-main {
+            font-size: 14px;
+            line-height: 1.65;
+            font-family: inherit;
+            display: block;
+            orphans: 3;
+            widows: 3;
+        }
         .question-score { margin-right: 6px; font-weight: 600; }
-        .question-stem { display: inline-block; font-size: 14px; font-family: inherit; }
-        .options { display: grid; row-gap: 8px; margin-top: 8px; }
+        .question-stem {
+            display: inline-block;
+            font-size: 14px;
+            font-family: inherit;
+            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 {
+            display: flex;
+            align-items: flex-start;
+            font-size: 14px;
+            line-height: 1.6;
+            page-break-inside: avoid;
+            break-inside: avoid;
         }
-        .option { display: flex; align-items: flex-start; font-size: 14px; line-height: 1.6; }
         .option strong { margin-right: 4px; }
         .option-compact { font-size: 14px; line-height: 1.6; }
-        .answer-area { position: relative; margin-top: 4px; }
+        /* 答案区域:不分页 */
+        .answer-area {
+            position: relative;
+            margin-top: 4px;
+            page-break-inside: avoid;
+            break-inside: avoid;
+        }
         .answer-area.boxy {
             min-height: 150px;
             border: 1.5px solid #444;
@@ -113,11 +171,14 @@
             color: #555;
             letter-spacing: 1px;
         }
+        /* 答案元信息:不分页 */
         .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 {
@@ -128,9 +189,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;