Spaces:
Sleeping
Sleeping
外層鎖死,內層撐開
Browse files鎖死外層:強制 #booking_table 這個元件的寬度絕對不能超過螢幕寬度 (max-width: 100vw),且超出部分直接切掉 (overflow: hidden)。這會殺死最外面的捲軸。
撐開內層:裡面的 table 強制設為 1500px,逼迫中間層 (.table-wrap) 必須產生捲軸。
欄位定寬:完全照您給的像素設定。
app.py
CHANGED
|
@@ -131,44 +131,46 @@ def check_login(user, password):
|
|
| 131 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 132 |
}
|
| 133 |
|
| 134 |
-
# --- 🔥 [
|
| 135 |
custom_css = """
|
| 136 |
-
/* 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
#booking_table .wrap {
|
| 138 |
-
|
| 139 |
-
|
|
|
|
| 140 |
}
|
| 141 |
|
| 142 |
-
/* 2.
|
| 143 |
-
#booking_table .table-wrap
|
| 144 |
-
|
| 145 |
-
overflow-x: auto !important;
|
| 146 |
overflow-y: hidden !important;
|
| 147 |
border: 1px solid #444 !important;
|
| 148 |
}
|
| 149 |
|
| 150 |
-
/* 3.
|
| 151 |
-
width: 1500px -> 【關鍵】設定一個大於所有欄位總和的寬度 (60+170+80+120+120+250+50+180+120+320 = 1470px)
|
| 152 |
-
table-layout: fixed -> 強制依照下方設定的寬度渲染,不讓瀏覽器壓縮
|
| 153 |
-
*/
|
| 154 |
#booking_table table {
|
| 155 |
table-layout: fixed !important;
|
| 156 |
-
width:
|
| 157 |
-
min-width:
|
| 158 |
border-collapse: collapse !important;
|
| 159 |
-
margin: 0 !important;
|
| 160 |
}
|
| 161 |
|
| 162 |
-
/* 4.
|
| 163 |
-
white-space: normal -> 【關鍵】允許換行
|
| 164 |
-
word-break: break-all -> 強制長單字(如User ID)換行
|
| 165 |
-
*/
|
| 166 |
#booking_table th, #booking_table td {
|
| 167 |
display: table-cell !important;
|
| 168 |
-
white-space: normal !important;
|
|
|
|
| 169 |
overflow-wrap: break-word !important;
|
| 170 |
-
word-break: break-all !important;
|
| 171 |
-
|
| 172 |
vertical-align: top !important;
|
| 173 |
box-sizing: border-box !important;
|
| 174 |
padding: 8px 5px !important;
|
|
@@ -177,7 +179,7 @@ custom_css = """
|
|
| 177 |
line-height: 1.4 !important;
|
| 178 |
}
|
| 179 |
|
| 180 |
-
/* 5.
|
| 181 |
#booking_table th:nth-child(1), #booking_table td:nth-child(1) { width: 60px !important; }
|
| 182 |
#booking_table th:nth-child(2), #booking_table td:nth-child(2) { width: 170px !important; }
|
| 183 |
#booking_table th:nth-child(3), #booking_table td:nth-child(3) { width: 80px !important; }
|
|
@@ -207,7 +209,7 @@ with gr.Blocks(title="Admin", css=custom_css) as demo:
|
|
| 207 |
gr.Markdown("# 🍷 訂位管理後台 (Dashboard)")
|
| 208 |
refresh_btn = gr.Button("🔄 重新整理")
|
| 209 |
|
| 210 |
-
# ✅ elem_id 保持為 booking_table
|
| 211 |
booking_table = gr.Dataframe(interactive=False, elem_id="booking_table")
|
| 212 |
|
| 213 |
with gr.Row():
|
|
|
|
| 131 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 132 |
}
|
| 133 |
|
| 134 |
+
# --- 🔥 [終極修正 CSS] 🔥 ---
|
| 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 |
+
/* 確保 Gradio 預設的 wrap 不會搗亂 */
|
| 146 |
#booking_table .wrap {
|
| 147 |
+
width: 100% !important;
|
| 148 |
+
max-width: 100% !important;
|
| 149 |
+
overflow: hidden !important;
|
| 150 |
}
|
| 151 |
|
| 152 |
+
/* 2. 【開啟內層】只允許這裡捲動 */
|
| 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 |
+
/* 3. 【撐開表格】 */
|
|
|
|
|
|
|
|
|
|
| 161 |
#booking_table table {
|
| 162 |
table-layout: fixed !important;
|
| 163 |
+
width: 1600px !important; /* 👈 硬性設定總寬度,總和大約是您各欄位加總 */
|
| 164 |
+
min-width: 1600px !important;
|
| 165 |
border-collapse: collapse !important;
|
|
|
|
| 166 |
}
|
| 167 |
|
| 168 |
+
/* 4. 【欄位行為】 */
|
|
|
|
|
|
|
|
|
|
| 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 |
line-height: 1.4 !important;
|
| 180 |
}
|
| 181 |
|
| 182 |
+
/* 5. 🔥【絕對欄寬】(依照您的指定) */
|
| 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; }
|
|
|
|
| 209 |
gr.Markdown("# 🍷 訂位管理後台 (Dashboard)")
|
| 210 |
refresh_btn = gr.Button("🔄 重新整理")
|
| 211 |
|
| 212 |
+
# ✅ elem_id 保持為 booking_table
|
| 213 |
booking_table = gr.Dataframe(interactive=False, elem_id="booking_table")
|
| 214 |
|
| 215 |
with gr.Row():
|