DeepLearning101 commited on
Commit
9fdde86
·
verified ·
1 Parent(s): 0b80a85

對「容器」執行 「截斷 (Clipping)」,只允許內部滑動。

Browse files

核心修正策略:
最外層 (#booking_table):overflow: hidden (絕對禁止溢出,殺死外層捲軸)。
中間層 (.wrap):width: 100% (強制跟隨螢幕寬度,不准被內容撐大)。
捲動層 (tbody-wrap / table-wrap):overflow-x: auto (唯一允許捲動的地方)。
內容層 (table):width: 1470px (這是您所有欄位寬度的總和,強制撐開)。

Files changed (1) hide show
  1. app.py +22 -33
app.py CHANGED
@@ -38,7 +38,6 @@ 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
  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,38 +131,28 @@ def check_login(user, password):
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;
@@ -171,21 +160,21 @@ custom_css = """
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;
@@ -201,7 +190,7 @@ custom_css = """
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; }
 
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
  error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
132
  }
133
 
134
+ # --- 🔥 [雙重捲軸修正 CSS] 🔥 ---
135
  custom_css = """
136
+ /* 1. 【鎖死外層】
137
+ #booking_table 及其直接包裝層 (.wrap) 的寬度鎖死在 100%。
138
+ 並且 overflow: hidden 強制切斷超出部分。這會消滅外層捲軸。
 
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
+ display: block !important;
147
  }
148
 
149
+ /* 2. 【開啟內層】
150
+ 找到真正包含表格的容器 (通常是 table-wrap tbody-wrap),
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
  overflow-x: auto !important;
158
  overflow-y: hidden !important;
 
160
  display: block !important;
161
  }
162
 
163
+ /* 3. 【撐開內容】
164
+ width: 1470px -> 將表格寬度設定為您所有欄位寬度的總和。
165
+ table-layout: fixed -> 強制每個欄位遵守寬度設定。
166
  */
167
  #booking_table table {
168
  table-layout: fixed !important;
169
+ width: 1470px !important; /* 60+170+80+120+120+250+50+180+120+320 = 1470 */
170
+ min-width: 1470px !important;
171
  border-collapse: collapse !important;
172
  margin: 0 !important;
173
  }
174
 
175
+ /* 4. 【欄位行為】
176
  white-space: normal -> 允許換行
177
+ word-break: break-all -> 強制換行
178
  */
179
  #booking_table th, #booking_table td {
180
  display: table-cell !important;
 
190
  line-height: 1.4 !important;
191
  }
192
 
193
+ /* 5. 🔥【絕對欄寬】(依照您的指定) */
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; }