雙重捲軸殺手
Browse files使用 「容器隔離法」。我們要把表格「關在」一個寬度絕對不超過螢幕的盒子裡,只允許這個盒子內部捲動。
app.py
CHANGED
|
@@ -38,6 +38,7 @@ def send_confirmation_hybrid(booking_id):
|
|
| 38 |
email, user_id = booking.get('email'), booking.get('user_id')
|
| 39 |
log_msg = ""
|
| 40 |
|
|
|
|
| 41 |
confirm_link = f"{PUBLIC_SPACE_URL}/?id={booking_id}&action=confirm"
|
| 42 |
cancel_link = f"{PUBLIC_SPACE_URL}/?id={booking_id}&action=cancel"
|
| 43 |
|
|
@@ -131,46 +132,67 @@ def check_login(user, password):
|
|
| 131 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 132 |
}
|
| 133 |
|
| 134 |
-
# --- 🔥 [
|
| 135 |
custom_css = """
|
| 136 |
-
/* 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
#booking_table {
|
| 138 |
display: block !important;
|
| 139 |
width: 100% !important;
|
| 140 |
-
max-width: 100vw !important;
|
| 141 |
-
overflow: hidden !important;
|
| 142 |
padding: 0 !important;
|
|
|
|
|
|
|
| 143 |
}
|
| 144 |
|
| 145 |
-
/*
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
| 147 |
width: 100% !important;
|
| 148 |
-
max-width:
|
| 149 |
overflow: hidden !important;
|
| 150 |
}
|
| 151 |
|
| 152 |
-
/*
|
|
|
|
|
|
|
|
|
|
| 153 |
#booking_table .table-wrap {
|
| 154 |
width: 100% !important;
|
| 155 |
-
overflow-x: auto !important;
|
| 156 |
overflow-y: hidden !important;
|
| 157 |
border: 1px solid #444 !important;
|
|
|
|
| 158 |
}
|
| 159 |
|
| 160 |
-
/*
|
|
|
|
|
|
|
|
|
|
| 161 |
#booking_table table {
|
| 162 |
table-layout: fixed !important;
|
| 163 |
-
width:
|
| 164 |
-
min-width:
|
| 165 |
border-collapse: collapse !important;
|
|
|
|
| 166 |
}
|
| 167 |
|
| 168 |
-
/*
|
|
|
|
|
|
|
|
|
|
| 169 |
#booking_table th, #booking_table td {
|
| 170 |
display: table-cell !important;
|
| 171 |
-
white-space: normal !important;
|
| 172 |
-
word-break: break-all !important; /* ✅ 強制換行 */
|
| 173 |
overflow-wrap: break-word !important;
|
|
|
|
|
|
|
| 174 |
vertical-align: top !important;
|
| 175 |
box-sizing: border-box !important;
|
| 176 |
padding: 8px 5px !important;
|
|
@@ -179,7 +201,7 @@ custom_css = """
|
|
| 179 |
line-height: 1.4 !important;
|
| 180 |
}
|
| 181 |
|
| 182 |
-
/*
|
| 183 |
#booking_table th:nth-child(1), #booking_table td:nth-child(1) { width: 60px !important; }
|
| 184 |
#booking_table th:nth-child(2), #booking_table td:nth-child(2) { width: 170px !important; }
|
| 185 |
#booking_table th:nth-child(3), #booking_table td:nth-child(3) { width: 80px !important; }
|
|
|
|
| 38 |
email, user_id = booking.get('email'), booking.get('user_id')
|
| 39 |
log_msg = ""
|
| 40 |
|
| 41 |
+
confirm_link = f"{PUBLIC_SPACE_URL}/?id={booking_id}&action=confirm"
|
| 42 |
confirm_link = f"{PUBLIC_SPACE_URL}/?id={booking_id}&action=confirm"
|
| 43 |
cancel_link = f"{PUBLIC_SPACE_URL}/?id={booking_id}&action=cancel"
|
| 44 |
|
|
|
|
| 132 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 133 |
}
|
| 134 |
|
| 135 |
+
# --- 🔥 [雙重捲軸殺手 CSS] 🔥 ---
|
| 136 |
custom_css = """
|
| 137 |
+
/* 1. 鎖定外層容器 (元件本體):
|
| 138 |
+
max-width: 100vw -> 確保整個元件寬度絕不超過螢幕
|
| 139 |
+
overflow: hidden -> 強制隱藏所有溢出,這是殺死外層捲軸的關鍵
|
| 140 |
+
display: block -> 確保它以區塊顯示
|
| 141 |
+
*/
|
| 142 |
#booking_table {
|
| 143 |
display: block !important;
|
| 144 |
width: 100% !important;
|
| 145 |
+
max-width: 100vw !important;
|
| 146 |
+
overflow: hidden !important;
|
| 147 |
padding: 0 !important;
|
| 148 |
+
margin: 0 !important;
|
| 149 |
+
border: none !important;
|
| 150 |
}
|
| 151 |
|
| 152 |
+
/* 2. 鎖定中間層 (Gradio 的包裝層):
|
| 153 |
+
這些通常是產生外層捲軸的元兇,全部隱藏 overflow
|
| 154 |
+
*/
|
| 155 |
+
#booking_table .wrap,
|
| 156 |
+
#booking_table .svelte-12cmxck {
|
| 157 |
width: 100% !important;
|
| 158 |
+
max-width: 100vw !important;
|
| 159 |
overflow: hidden !important;
|
| 160 |
}
|
| 161 |
|
| 162 |
+
/* 3. 開放內層容器 (真正包著 table 的層):
|
| 163 |
+
overflow-x: auto -> 這裡且「只有這裡」允許水平捲動
|
| 164 |
+
width: 100% -> 寬度跟隨父容器 (螢幕寬)
|
| 165 |
+
*/
|
| 166 |
#booking_table .table-wrap {
|
| 167 |
width: 100% !important;
|
| 168 |
+
overflow-x: auto !important;
|
| 169 |
overflow-y: hidden !important;
|
| 170 |
border: 1px solid #444 !important;
|
| 171 |
+
display: block !important;
|
| 172 |
}
|
| 173 |
|
| 174 |
+
/* 4. 表格本體:
|
| 175 |
+
width: 1500px -> 設定一個大於所有欄位總和的定值 (確保撐開捲軸)
|
| 176 |
+
table-layout: fixed -> 嚴格執行欄位寬度
|
| 177 |
+
*/
|
| 178 |
#booking_table table {
|
| 179 |
table-layout: fixed !important;
|
| 180 |
+
width: 1500px !important;
|
| 181 |
+
min-width: 1500px !important;
|
| 182 |
border-collapse: collapse !important;
|
| 183 |
+
margin: 0 !important;
|
| 184 |
}
|
| 185 |
|
| 186 |
+
/* 5. 欄位通用設定:
|
| 187 |
+
white-space: normal -> 允許換行
|
| 188 |
+
word-break: break-all -> 強制換行 (避免 user_id 撐開)
|
| 189 |
+
*/
|
| 190 |
#booking_table th, #booking_table td {
|
| 191 |
display: table-cell !important;
|
| 192 |
+
white-space: normal !important;
|
|
|
|
| 193 |
overflow-wrap: break-word !important;
|
| 194 |
+
word-break: break-all !important;
|
| 195 |
+
|
| 196 |
vertical-align: top !important;
|
| 197 |
box-sizing: border-box !important;
|
| 198 |
padding: 8px 5px !important;
|
|
|
|
| 201 |
line-height: 1.4 !important;
|
| 202 |
}
|
| 203 |
|
| 204 |
+
/* 6. 🔥【您的指定欄寬】(10個欄位) */
|
| 205 |
#booking_table th:nth-child(1), #booking_table td:nth-child(1) { width: 60px !important; }
|
| 206 |
#booking_table th:nth-child(2), #booking_table td:nth-child(2) { width: 170px !important; }
|
| 207 |
#booking_table th:nth-child(3), #booking_table td:nth-child(3) { width: 80px !important; }
|