Spaces:
Sleeping
排版重構:修正頂部列/底部連結沒有真正置頂置底
Browse files千卉實機在 localhost 玩過之後回報:頂部列(D)沒有真正固定在頂端、
底部「透過API使用/設定」連結也沒有固定在底部。
實測用 devtools 沿著 <footer> 往上逐層量 computed style 找到真因:
Gradio 原生把 gradio-app/.gradio-container/.app/.wrap 這四層全部
設成 display:flex; flex-direction:column,.wrap 底下正好是「主內容
(.contain)+footer」兩個 flex 子項——結構本來就對,問題是這條鏈
的高度全部是 auto(依內容撐高),不是鎖定 100vh。內容只要比視窗高
一點點,整個外層文件就會跟著捲動,把「該固定」的頂部列/底部連結一起
拖走。
修法:把這條 Gradio 原生就是 flex column 的鏈路鎖死在 100vh,
.contain(真正裝 gr.Blocks 內容那層)變成唯一會捲動的區域,footer
用 flex-shrink:0 釘住。完全不用 position:sticky/fixed——8-B 已經踩過
sticky 在 Gradio 自動包的 wrapper 裡貼不住的坑,這次延續「結構性
分離,不依賴 sticky」的既有原則,只是這次分離的是整個頁面殼,不只
單一元件。連帶讓 nav-col 也比照 chat-col/canvas-col 鎖定高度+自己
捲動,避免手風琴展開等情況把 nav-col 撐高、間接逼 .contain 整層捲動。
已用 Playwright 驗證:桌面/短視窗(550px,手風琴展開強制觸發溢出)/
手機375px 三種情境下 document.documentElement.scrollHeight 都精確
等於視窗高度,完全無外層捲動;nav-col 在短視窗下正確改成自己內部
捲動;首頁/設定面板/reset流程皆不受影響;console 0 error。
- app_agent.py +54 -0
|
@@ -1859,6 +1859,50 @@ _CUSTOM_CSS = """
|
|
| 1859 |
margin-left: 0 !important;
|
| 1860 |
margin-right: 0 !important;
|
| 1861 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1862 |
*, *::before, *::after { box-sizing: border-box; }
|
| 1863 |
/* 全域安全網(陷阱 13 第 3 點):Gradio 的 markdown 渲染統一包在
|
| 1864 |
<span class="md ...">,預設是 inline 卻常常裝 block 層級的 <p>/<ul> 等,
|
|
@@ -2302,12 +2346,22 @@ div[role="log"][aria-label="chatbot conversation"],
|
|
| 2302 |
/* Phase 8-B:三欄式工作區。nav-col 窄、固定寬度不隨視窗縮放;chat-col/
|
| 2303 |
canvas-col 各自獨立捲動(各自的內容不會因為對方變長而互相影響),高度
|
| 2304 |
統一扣掉頁面上方 Tab 列與外距抓一個概略值,之後看實際渲染再微調 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2305 |
.nav-col {
|
| 2306 |
flex: 0 0 220px !important;
|
| 2307 |
max-width: 220px !important;
|
| 2308 |
display: flex !important;
|
| 2309 |
flex-direction: column !important;
|
| 2310 |
gap: .6rem !important;
|
|
|
|
|
|
|
|
|
|
| 2311 |
}
|
| 2312 |
/* 真因排查記錄:Gradio 的 .column 預設會帶 flex-wrap:wrap。平常沒設高度時
|
| 2313 |
不會有事,但這裡額外設了固定 height 讓內容用捲動取代撐高,一旦內容總高
|
|
|
|
| 1859 |
margin-left: 0 !important;
|
| 1860 |
margin-right: 0 !important;
|
| 1861 |
}
|
| 1862 |
+
/* 2026-07-23:千卉回報頂部列(D)沒有真正固定置頂、底部「透過API使用/
|
| 1863 |
+
設定」(G)也沒有固定置底。實測用 devtools 沿著 <footer> 往上量整條
|
| 1864 |
+
祖先鏈才發現:Gradio 原生把 gradio-app/.gradio-container/.app/
|
| 1865 |
+
.wrap 這四層全部設成 display:flex; flex-direction:column,.wrap 底下
|
| 1866 |
+
剛好就是「主內容(.contain)+footer」兩個 flex 子項——結構本來就是
|
| 1867 |
+
對的,問題是這條鏈的高度全部用 auto(依內容撐高),不是真正鎖定
|
| 1868 |
+
100vh。內容只要比視窗高一點點(哪怕只多15px),整個外層文件就會
|
| 1869 |
+
跟著捲動,把「理論上該固定」的頂部列/底部連結一起拖走——這才是
|
| 1870 |
+
「沒有真正置頂/置底」的根本原因,不是 sticky/fixed 沒設對。
|
| 1871 |
+
修法:把這條 Gradio 原生就是 flex column 的鏈路鎖死在 100vh,讓
|
| 1872 |
+
.contain(真正裝我們 gr.Blocks 內容的那層)變成唯一會捲動的區域,
|
| 1873 |
+
footer 用 flex-shrink:0 釘在最底。這樣完全不用碰 position:sticky/
|
| 1874 |
+
fixed(8-B 已經踩過 sticky 在 Gradio wrapper 裡貼不住的坑),延續
|
| 1875 |
+
這個檔案「結構性分離,不依賴 sticky」的既有原則,只是這次分離的
|
| 1876 |
+
層級是整個頁面殼,不只是單一元件。 */
|
| 1877 |
+
html, body {
|
| 1878 |
+
height: 100% !important;
|
| 1879 |
+
margin: 0 !important;
|
| 1880 |
+
}
|
| 1881 |
+
gradio-app {
|
| 1882 |
+
display: block !important;
|
| 1883 |
+
height: 100vh !important;
|
| 1884 |
+
overflow: hidden !important;
|
| 1885 |
+
}
|
| 1886 |
+
.gradio-container {
|
| 1887 |
+
height: 100vh !important;
|
| 1888 |
+
overflow: hidden !important;
|
| 1889 |
+
}
|
| 1890 |
+
.app {
|
| 1891 |
+
height: 100% !important;
|
| 1892 |
+
overflow: hidden !important;
|
| 1893 |
+
}
|
| 1894 |
+
.wrap {
|
| 1895 |
+
height: 100% !important;
|
| 1896 |
+
overflow: hidden !important;
|
| 1897 |
+
}
|
| 1898 |
+
.contain {
|
| 1899 |
+
flex: 1 1 auto !important;
|
| 1900 |
+
min-height: 0 !important;
|
| 1901 |
+
overflow-y: auto !important;
|
| 1902 |
+
}
|
| 1903 |
+
footer {
|
| 1904 |
+
flex-shrink: 0 !important;
|
| 1905 |
+
}
|
| 1906 |
*, *::before, *::after { box-sizing: border-box; }
|
| 1907 |
/* 全域安全網(陷阱 13 第 3 點):Gradio 的 markdown 渲染統一包在
|
| 1908 |
<span class="md ...">,預設是 inline 卻常常裝 block 層級的 <p>/<ul> 等,
|
|
|
|
| 2346 |
/* Phase 8-B:三欄式工作區。nav-col 窄、固定寬度不隨視窗縮放;chat-col/
|
| 2347 |
canvas-col 各自獨立捲動(各自的內容不會因為對方變長而互相影響),高度
|
| 2348 |
統一扣掉頁面上方 Tab 列與外距抓一個概略值,之後看實際渲染再微調 */
|
| 2349 |
+
/* 2026-07-23:跟 chat-col/canvas-col 一樣鎖定高度+自己捲動,理由是
|
| 2350 |
+
頁殼改成真 100vh 鎖死之後(見上方 .contain 那組規則),nav-col 如果
|
| 2351 |
+
內容比這個高度多(手風琴展開+8個導覽項目在矮視窗上有可能發生),
|
| 2352 |
+
沒有自己的 overflow 就會撐開 .main-layout-row,逼 .contain 整層捲動
|
| 2353 |
+
——雖然不會再拖走頂部列/footer了(那兩個已經在 .contain 外面),但
|
| 2354 |
+
chat-col/canvas-col 會跟著被迫一起捲動,體驗還是不對。讓三欄各自
|
| 2355 |
+
獨立捲動,互不影響。 */
|
| 2356 |
.nav-col {
|
| 2357 |
flex: 0 0 220px !important;
|
| 2358 |
max-width: 220px !important;
|
| 2359 |
display: flex !important;
|
| 2360 |
flex-direction: column !important;
|
| 2361 |
gap: .6rem !important;
|
| 2362 |
+
height: calc(100vh - 150px) !important;
|
| 2363 |
+
overflow-y: auto !important;
|
| 2364 |
+
overflow-x: hidden !important;
|
| 2365 |
}
|
| 2366 |
/* 真因排查記錄:Gradio 的 .column 預設會帶 flex-wrap:wrap。平常沒設高度時
|
| 2367 |
不會有事,但這裡額外設了固定 height 讓內容用捲動取代撐高,一旦內容總高
|