DeepLearning101 commited on
Commit
393c970
·
verified ·
1 Parent(s): cc92110

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -17
app.py CHANGED
@@ -133,43 +133,42 @@ def check_login(user, password):
133
  error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
134
  }
135
 
136
- # --- 🔥 [最終修正 CSS]:不換行 + 撐開 + 捲軸 ---
137
  custom_css = """
138
- /* 1. 確保外層容器可以 */
139
- div[data-testid="dataframe"] {
140
  overflow-x: auto !important;
141
- max-width: 100vw !important; /* 確保容器本身不超過螢幕寬 */
142
  display: block !important;
143
  }
144
 
145
  /* 2. 表格本體:
146
- min-width: max-content 是關鍵!
147
- 它告訴瀏覽器:表格的最小寬度 = 內容完全展開後的總長度。
148
- 這會迫使外層容器產生捲軸,而不是壓縮表格。
149
  */
150
  table {
151
- min-width: max-content !important;
152
  width: auto !important;
153
  border-collapse: collapse !important;
154
  }
155
 
156
- /* 3. 欄位設定:強制不換行 */
 
 
 
157
  td, th {
158
- white-space: nowrap !important; /* 🚫 絕對禁止換行 */
159
- overflow: visible !important;
160
- text-overflow: clip !important; /* 移除 ... */
161
-
162
- /* 移除寬度限制,讓內容自己決定要多寬 */
163
  max-width: none !important;
164
  width: auto !important;
165
 
166
- padding: 8px 12px !important; /* 舒適間距 */
 
167
  }
168
 
169
- /* 4. 針對 Gradio 內部的 span 也強制不換行 */
170
  td > span, th > span {
171
  white-space: nowrap !important;
172
- overflow: visible !important;
173
  }
174
  """
175
 
 
133
  error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
134
  }
135
 
136
+ # --- 🔥 [回歸傳統 CSS]:不換行 + 強制捲動 ---
137
  custom_css = """
138
+ /* 1. 外層容器:強制開啟水平 */
139
+ .table-wrap, .svelte-12cmxck, .wrap {
140
  overflow-x: auto !important;
 
141
  display: block !important;
142
  }
143
 
144
  /* 2. 表格本體:
145
+ width: auto -> 內容多少寬度就多少
146
+ table-layout: auto -> 自動依內容計算
 
147
  */
148
  table {
149
+ table-layout: auto !important;
150
  width: auto !important;
151
  border-collapse: collapse !important;
152
  }
153
 
154
+ /* 3. 欄位設定:
155
+ white-space: nowrap -> 死都不准換行 (這會把表格撐寬)
156
+ max-width: none -> 移除任何寬度限制
157
+ */
158
  td, th {
159
+ white-space: nowrap !important;
160
+ min-width: 10px !important; /* 防止縮太小 */
 
 
 
161
  max-width: none !important;
162
  width: auto !important;
163
 
164
+ padding: 8px 12px !important;
165
+ border: 1px solid #444 !important; /* 加上邊框比較清楚 */
166
  }
167
 
168
+ /* 4. Gradio 內部的 span */
169
  td > span, th > span {
170
  white-space: nowrap !important;
171
+ display: inline-block !important;
172
  }
173
  """
174