結構穿透修正版
Browse files用 CSS 子代選擇器 (>) 來實施 「精準斬首」: 我們直接命令 #booking_table 底下的所有第一層 div 都不准捲動,只准更深層的表格捲動。
app.py
CHANGED
|
@@ -131,58 +131,60 @@ def check_login(user, password):
|
|
| 131 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 132 |
}
|
| 133 |
|
| 134 |
-
# --- 🔥 [
|
| 135 |
custom_css = """
|
| 136 |
-
/* 1.
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
| 139 |
max-width: 100vw !important;
|
| 140 |
-
width: 100vw !important;
|
| 141 |
-
overflow-x: hidden !important; /* 👈 這是殺死長捲軸的關鍵 */
|
| 142 |
-
padding: 0 !important;
|
| 143 |
-
margin: 0 !important;
|
| 144 |
}
|
| 145 |
|
| 146 |
-
/* 2.
|
|
|
|
|
|
|
| 147 |
#booking_table {
|
| 148 |
-
width: 100% !important;
|
| 149 |
-
max-width: 100% !important;
|
| 150 |
overflow: hidden !important;
|
|
|
|
| 151 |
border: none !important;
|
| 152 |
}
|
| 153 |
|
| 154 |
-
/*
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
| 158 |
overflow: hidden !important;
|
|
|
|
| 159 |
}
|
| 160 |
|
| 161 |
-
/*
|
|
|
|
|
|
|
| 162 |
#booking_table .table-wrap {
|
| 163 |
-
|
| 164 |
-
overflow-x: auto !important; /* 👈 只允許這裡捲動 */
|
| 165 |
overflow-y: hidden !important;
|
| 166 |
border: 1px solid #444 !important;
|
| 167 |
-
/* 增加平滑捲動體驗 */
|
| 168 |
-
-webkit-overflow-scrolling: touch;
|
| 169 |
}
|
| 170 |
|
| 171 |
-
/*
|
| 172 |
#booking_table table {
|
| 173 |
table-layout: fixed !important;
|
| 174 |
-
/* 您的欄位寬度總和是 1470px,這裡設定 1500px 確保有空間 */
|
| 175 |
width: 1500px !important;
|
| 176 |
min-width: 1500px !important;
|
| 177 |
border-collapse: collapse !important;
|
| 178 |
margin: 0 !important;
|
| 179 |
}
|
| 180 |
|
| 181 |
-
/*
|
| 182 |
#booking_table th, #booking_table td {
|
| 183 |
-
|
| 184 |
-
|
| 185 |
overflow-wrap: break-word !important;
|
|
|
|
|
|
|
| 186 |
vertical-align: top !important;
|
| 187 |
box-sizing: border-box !important;
|
| 188 |
padding: 8px 5px !important;
|
|
@@ -191,7 +193,7 @@ custom_css = """
|
|
| 191 |
line-height: 1.4 !important;
|
| 192 |
}
|
| 193 |
|
| 194 |
-
/*
|
| 195 |
#booking_table th:nth-child(1), #booking_table td:nth-child(1) { width: 60px !important; }
|
| 196 |
#booking_table th:nth-child(2), #booking_table td:nth-child(2) { width: 170px !important; }
|
| 197 |
#booking_table th:nth-child(3), #booking_table td:nth-child(3) { width: 80px !important; }
|
|
|
|
| 131 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 132 |
}
|
| 133 |
|
| 134 |
+
# --- 🔥 [結構穿透 CSS]:精準殺死中層捲軸 🔥 ---
|
| 135 |
custom_css = """
|
| 136 |
+
/* 1. 【全域鎖死】
|
| 137 |
+
防止整個頁面因為表格太寬而產生瀏覽器級別的水平捲軸
|
| 138 |
+
*/
|
| 139 |
+
body, .gradio-container {
|
| 140 |
+
overflow-x: hidden !important;
|
| 141 |
max-width: 100vw !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
}
|
| 143 |
|
| 144 |
+
/* 2. 【ID層鎖死】
|
| 145 |
+
鎖定我們指定的元件外層
|
| 146 |
+
*/
|
| 147 |
#booking_table {
|
|
|
|
|
|
|
| 148 |
overflow: hidden !important;
|
| 149 |
+
max-width: 100% !important;
|
| 150 |
border: none !important;
|
| 151 |
}
|
| 152 |
|
| 153 |
+
/* 3. 🔥【關鍵修正:殺死中間層】🔥
|
| 154 |
+
選取 #booking_table 底下的「直接子元素 div」。
|
| 155 |
+
這通常就是那個帶有 'wrap' class 且預設 overflow:auto 的傢伙。
|
| 156 |
+
我們強制把它隱藏,這就是您一直在找的「外層捲軸」控制點!
|
| 157 |
+
*/
|
| 158 |
+
#booking_table > div {
|
| 159 |
overflow: hidden !important;
|
| 160 |
+
border: none !important;
|
| 161 |
}
|
| 162 |
|
| 163 |
+
/* 4. 【復活內層】
|
| 164 |
+
找到真正包含 table 的那一層 (通常是 .table-wrap),只有這裡可以捲動。
|
| 165 |
+
*/
|
| 166 |
#booking_table .table-wrap {
|
| 167 |
+
overflow-x: auto !important;
|
|
|
|
| 168 |
overflow-y: hidden !important;
|
| 169 |
border: 1px solid #444 !important;
|
|
|
|
|
|
|
| 170 |
}
|
| 171 |
|
| 172 |
+
/* 5. 【表格定寬】(您的設定) */
|
| 173 |
#booking_table table {
|
| 174 |
table-layout: fixed !important;
|
|
|
|
| 175 |
width: 1500px !important;
|
| 176 |
min-width: 1500px !important;
|
| 177 |
border-collapse: collapse !important;
|
| 178 |
margin: 0 !important;
|
| 179 |
}
|
| 180 |
|
| 181 |
+
/* 6. 【欄位行為】 */
|
| 182 |
#booking_table th, #booking_table td {
|
| 183 |
+
display: table-cell !important;
|
| 184 |
+
white-space: normal !important;
|
| 185 |
overflow-wrap: break-word !important;
|
| 186 |
+
word-break: break-all !important;
|
| 187 |
+
|
| 188 |
vertical-align: top !important;
|
| 189 |
box-sizing: border-box !important;
|
| 190 |
padding: 8px 5px !important;
|
|
|
|
| 193 |
line-height: 1.4 !important;
|
| 194 |
}
|
| 195 |
|
| 196 |
+
/* 7. 【欄位寬度】 */
|
| 197 |
#booking_table th:nth-child(1), #booking_table td:nth-child(1) { width: 60px !important; }
|
| 198 |
#booking_table th:nth-child(2), #booking_table td:nth-child(2) { width: 170px !important; }
|
| 199 |
#booking_table th:nth-child(3), #booking_table td:nth-child(3) { width: 80px !important; }
|