DeepLearning101 commited on
Commit
ec2eb9c
·
verified ·
1 Parent(s): 45bbc39

結構穿透修正版

Browse files

用 CSS 子代選擇器 (>) 來實施 「精準斬首」: 我們直接命令 #booking_table 底下的所有第一層 div 都不准捲動,只准更深層的表格捲動。

Files changed (1) hide show
  1. app.py +28 -26
app.py CHANGED
@@ -131,58 +131,60 @@ def check_login(user, password):
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,7 +193,7 @@ custom_css = """
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; }
 
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; }