Browse Source

fix(pdf): prevent grading/exam question overlap on long content

yemeishu 3 months ago
parent
commit
e68c23b74b
2 changed files with 48 additions and 15 deletions
  1. 30 13
      resources/views/pdf/exam-grading.blade.php
  2. 18 2
      resources/views/pdf/exam-paper.blade.php

+ 30 - 13
resources/views/pdf/exam-grading.blade.php

@@ -77,9 +77,11 @@
         /* 题目整体:不分页 */
         .question {
             margin-bottom: 14px;
-            page-break-inside: avoid;
-            break-inside: avoid;
-            -webkit-column-break-inside: avoid;
+            /* 判卷解析可能很长(含多图),允许跨页以避免叠压到下一题 */
+            page-break-inside: auto;
+            break-inside: auto;
+            -webkit-column-break-inside: auto;
+            clear: both;
         }
         /* 题目网格:不分页 */
         .question-grid {
@@ -88,8 +90,8 @@
             column-gap: 4px;
             row-gap: 6px;
             align-items: flex-start;
-            page-break-inside: avoid;
-            break-inside: avoid;
+            page-break-inside: auto;
+            break-inside: auto;
         }
         .question-lead {
             display: flex;
@@ -115,7 +117,7 @@
         }
         .question-score { margin-right: 6px; font-weight: 600; }
         .question-stem {
-            display: inline-block;
+            display: block;
             font-size: 14px;
             font-family: inherit;
             orphans: 3;
@@ -219,8 +221,8 @@
             color: #2f2f2f;
             line-height: 1.75;
             margin-top: 4px;
-            page-break-inside: avoid;
-            break-inside: avoid;
+            page-break-inside: auto;
+            break-inside: auto;
         }
         .answer-line + .answer-line { margin-top: 4px; }
         .solution-step {
@@ -230,13 +232,13 @@
         .step-box { display: inline-block; }
         .step-label { white-space: nowrap; }
         .solution-heading { font-weight: 700; }
-        .solution-content { display: inline-block; line-height: 1.75; }
+        .solution-content { display: inline; line-height: 1.75; }
         /* 解析区域:不分页 */
         .solution-section {
             margin-top: 8px;
             padding: 6px 8px;
-            page-break-inside: avoid;
-            break-inside: avoid;
+            page-break-inside: auto;
+            break-inside: auto;
         }
         .solution-section strong {
             font-size: 13px;
@@ -316,18 +318,33 @@
         .solution-content img,
         .solution-section img,
         .solution-parsed img {
-            display: block;
+            display: block !important;
             max-width: 220px;
             max-height: 60mm;
             width: auto;
             height: auto;
-            margin: 6px auto;
+            margin: 6px auto !important;
+            float: none !important;
+            clear: both !important;
+            position: static !important;
             box-sizing: border-box;
             object-fit: contain;
             -webkit-print-color-adjust: exact;
             print-color-adjust: exact;
             image-rendering: -webkit-optimize-contrast;
         }
+        .question-stem svg,
+        .question-main svg,
+        .answer-meta svg,
+        .solution-content svg,
+        .solution-section svg,
+        .solution-parsed svg {
+            float: none !important;
+            clear: both !important;
+            position: static !important;
+            margin: 8px auto !important;
+            display: block !important;
+        }
         /* 选项中的图片样式 - 防止超出容器 */
         .option img {
             max-width: 100%;

+ 18 - 2
resources/views/pdf/exam-paper.blade.php

@@ -113,6 +113,7 @@
             page-break-inside: avoid;
             break-inside: avoid;
             -webkit-column-break-inside: avoid;
+            clear: both;
         }
         /* 题目网格:不分页 */
         .question-grid {
@@ -399,18 +400,33 @@
         .solution-content img,
         .solution-section img,
         .solution-parsed img {
-            display: block;
+            display: block !important;
             max-width: 220px;
             max-height: 60mm;
             width: auto;
             height: auto;
-            margin: 6px auto;
+            margin: 6px auto !important;
+            float: none !important;
+            clear: both !important;
+            position: static !important;
             box-sizing: border-box;
             object-fit: contain;
             -webkit-print-color-adjust: exact;
             print-color-adjust: exact;
             image-rendering: -webkit-optimize-contrast;
         }
+        .question-stem svg,
+        .question-main svg,
+        .answer-meta svg,
+        .solution-content svg,
+        .solution-section svg,
+        .solution-parsed svg {
+            float: none !important;
+            clear: both !important;
+            position: static !important;
+            margin: 8px auto !important;
+            display: block !important;
+        }
         /* 选项中的图片样式 - 防止超出容器 */
         .option img {
             max-width: 100%;