全域鎖定終極版
Browse files鎖死 body 和 .gradio-container:強制設定 max-width: 100vw 且 overflow-x: hidden。這會告訴瀏覽器:「不管裡面多大,網頁本身絕對不准出現水平捲軸」。
鎖死元件外層:#booking_table 也必須鎖死在 100% 寬度。
只開放 .table-wrap:這是唯一允許 overflow-x: auto 的地方。
app.py
CHANGED
|
@@ -131,57 +131,58 @@ def check_login(user, password):
|
|
| 131 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 132 |
}
|
| 133 |
|
| 134 |
-
# --- 🔥 [
|
| 135 |
custom_css = """
|
| 136 |
-
/* 1.
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
*/
|
| 140 |
-
#booking_table,
|
| 141 |
-
#booking_table > .wrap,
|
| 142 |
-
#booking_table .gradio-container {
|
| 143 |
-
width: 100% !important;
|
| 144 |
max-width: 100vw !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
overflow: hidden !important;
|
| 146 |
-
|
| 147 |
}
|
| 148 |
|
| 149 |
-
/*
|
| 150 |
-
|
| 151 |
-
只讓它擁有 overflow-x: auto。
|
| 152 |
-
*/
|
| 153 |
-
#booking_table .table-wrap,
|
| 154 |
-
#booking_table div[class*="table"],
|
| 155 |
-
#booking_table .tbody-wrap {
|
| 156 |
width: 100% !important;
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
overflow-y: hidden !important;
|
| 159 |
border: 1px solid #444 !important;
|
| 160 |
-
|
|
|
|
| 161 |
}
|
| 162 |
|
| 163 |
-
/*
|
| 164 |
-
width: 1470px -> 將表格寬度設定為您所有欄位寬度的總和。
|
| 165 |
-
table-layout: fixed -> 強制每個欄位遵守寬度設定。
|
| 166 |
-
*/
|
| 167 |
#booking_table table {
|
| 168 |
table-layout: fixed !important;
|
| 169 |
-
|
| 170 |
-
|
|
|
|
| 171 |
border-collapse: collapse !important;
|
| 172 |
margin: 0 !important;
|
| 173 |
}
|
| 174 |
|
| 175 |
-
/*
|
| 176 |
-
white-space: normal -> 允許換行
|
| 177 |
-
word-break: break-all -> 強制換行
|
| 178 |
-
*/
|
| 179 |
#booking_table th, #booking_table td {
|
| 180 |
-
|
| 181 |
-
|
| 182 |
overflow-wrap: break-word !important;
|
| 183 |
-
word-break: break-all !important;
|
| 184 |
-
|
| 185 |
vertical-align: top !important;
|
| 186 |
box-sizing: border-box !important;
|
| 187 |
padding: 8px 5px !important;
|
|
@@ -190,7 +191,7 @@ custom_css = """
|
|
| 190 |
line-height: 1.4 !important;
|
| 191 |
}
|
| 192 |
|
| 193 |
-
/*
|
| 194 |
#booking_table th:nth-child(1), #booking_table td:nth-child(1) { width: 60px !important; }
|
| 195 |
#booking_table th:nth-child(2), #booking_table td:nth-child(2) { width: 170px !important; }
|
| 196 |
#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 |
+
.gradio-container, body {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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. 【元件鎖死】殺死 Dataframe 元件層級的捲軸 */
|
| 147 |
+
#booking_table {
|
| 148 |
+
width: 100% !important;
|
| 149 |
+
max-width: 100% !important;
|
| 150 |
overflow: hidden !important;
|
| 151 |
+
border: none !important;
|
| 152 |
}
|
| 153 |
|
| 154 |
+
/* 鎖死 Gradio 預設的包裝層 */
|
| 155 |
+
#booking_table .wrap, #booking_table .svelte-12cmxck {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
width: 100% !important;
|
| 157 |
+
max-width: 100% !important;
|
| 158 |
+
overflow: hidden !important;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
/* 3. 【開放內層】這才是我們要的唯一捲軸 */
|
| 162 |
+
#booking_table .table-wrap {
|
| 163 |
+
width: 100% !important;
|
| 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 |
+
/* 4. 【表格定寬】 */
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/* 5. 【欄位行為】 */
|
|
|
|
|
|
|
|
|
|
| 182 |
#booking_table th, #booking_table td {
|
| 183 |
+
white-space: normal !important; /* 允許換行 */
|
| 184 |
+
word-break: break-all !important; /* 強制換行 */
|
| 185 |
overflow-wrap: break-word !important;
|
|
|
|
|
|
|
| 186 |
vertical-align: top !important;
|
| 187 |
box-sizing: border-box !important;
|
| 188 |
padding: 8px 5px !important;
|
|
|
|
| 191 |
line-height: 1.4 !important;
|
| 192 |
}
|
| 193 |
|
| 194 |
+
/* 6. 🔥【您的指定欄寬】(完全依照數值) */
|
| 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; }
|