DeepLearning101 commited on
Commit
d76c9c6
·
verified ·
1 Parent(s): bbd9442

網頁前端的寬度設定與 Streamlit 預設字體大小在手機上打架

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +30 -29
src/streamlit_app.py CHANGED
@@ -10,49 +10,50 @@ st.markdown(
10
  """
11
  <style>
12
  /* 1. 隱藏側邊欄捲軸 */
13
- [data-testid="stSidebar"] section::-webkit-scrollbar {
14
- display: none;
15
- }
16
- [data-testid="stSidebar"] section {
17
- -ms-overflow-style: none;
18
- scrollbar-width: none;
19
  }
20
 
21
- /* 2. 調整範例按鈕樣式 (維持科技藍) */
22
  .stButton button {
23
- width: auto;
24
- padding: 5px 15px;
25
- border-radius: 20px;
26
- border: 1px solid #58a6ff;
27
- color: #58a6ff;
28
  background-color: transparent;
 
 
 
 
 
29
  }
30
 
31
- /* 🚀 3. 關鍵修正:隱藏 Header 背景與右側選單,但保留左側展開按鈕 */
32
- header[data-testid="stHeader"] {
33
- background-color: rgba(0,0,0,0) !important; /* 背景透明 */
34
- color: #58a6ff !important;
 
 
35
  }
36
 
37
- /* 隱藏右側的「...」選單按鈕 */
 
 
 
38
  header[data-testid="stHeader"] #MainMenu {
39
  visibility: hidden;
40
  }
41
-
42
- /* 確保左側的展開按鈕 (CollapsedControl) 是可見的 */
43
  div[data-testid="collapsedControl"] {
44
  visibility: visible !important;
45
- background-color: #0d1117 !important; /* 給它一點深色背景,免得在白色畫面上看不見 */
 
46
  border-radius: 0 5px 5px 0;
47
- top: 10px;
48
- }
49
-
50
- /* 4. 壓縮主畫面邊距 */
51
- .block-container {
52
- padding-top: 2rem !important;
53
- padding-bottom: 5rem !important;
54
- padding-left: 1rem !important;
55
- padding-right: 1rem !important;
56
  }
57
  </style>
58
  """,
 
10
  """
11
  <style>
12
  /* 1. 隱藏側邊欄捲軸 */
13
+ [data-testid="stSidebar"] section::-webkit-scrollbar { display: none; }
14
+ [data-testid="stSidebar"] section { -ms-overflow-style: none; scrollbar-width: none; }
15
+
16
+ /* 🚀 2. 全域字體縮小,適應手機螢幕 */
17
+ html, body, [class*="st-"] {
18
+ font-size: 14px !important;
19
  }
20
 
21
+ /* 🚀 3. 調整範例按鈕樣式:變矮、字體變小、支援多行自動折行 */
22
  .stButton button {
23
+ width: 100%;
24
+ padding: 6px 10px; /* 縮小上下內距 */
25
+ border-radius: 12px;
26
+ border: 1px solid #D4AF37;
27
+ color: #D4AF37;
28
  background-color: transparent;
29
+ font-size: 13px !important; /* 讓按鈕字體再小一點 */
30
+ line-height: 1.3;
31
+ min-height: auto;
32
+ white-space: normal; /* 允許長句子自動折行,避免撐爆寬度 */
33
+ height: auto;
34
  }
35
 
36
+ /* 4. 極度壓縮主畫面空白 */
37
+ .block-container {
38
+ padding-top: 1.2rem !important;
39
+ padding-bottom: 5rem !important;
40
+ padding-left: 0.8rem !important;
41
+ padding-right: 0.8rem !important;
42
  }
43
 
44
+ /* 5. 隱藏 Header 背景與右側選單,但保留左側展開按鈕 */
45
+ header[data-testid="stHeader"] {
46
+ background-color: rgba(0,0,0,0) !important;
47
+ }
48
  header[data-testid="stHeader"] #MainMenu {
49
  visibility: hidden;
50
  }
 
 
51
  div[data-testid="collapsedControl"] {
52
  visibility: visible !important;
53
+ background-color: #1A1A1A !important;
54
+ color: #D4AF37 !important;
55
  border-radius: 0 5px 5px 0;
56
+ top: 5px;
 
 
 
 
 
 
 
 
57
  }
58
  </style>
59
  """,