我試圖在<LeftNav>
組件內部創建一個粘性頁腳,目前爲止失敗。這是什麼是需要的樣子:如何在LeftNav內創建粘性頁腳?
我已經在搜索領域的包裝使用position: fixed; bottom: 0
和position: absolute; bottom: 0
試過,但是當用戶滾動列表項的搜索欄移動起來。就像這樣:
任何想法如何解決這一問題?
我試圖在<LeftNav>
組件內部創建一個粘性頁腳,目前爲止失敗。這是什麼是需要的樣子:如何在LeftNav內創建粘性頁腳?
我已經在搜索領域的包裝使用position: fixed; bottom: 0
和position: absolute; bottom: 0
試過,但是當用戶滾動列表項的搜索欄移動起來。就像這樣:
任何想法如何解決這一問題?
職位:固定應該工作。如果沒有關於您如何進行網頁設置的更多信息,則很難更具體。看看這個小提琴,看看是否有幫助:
https://jsfiddle.net/kevinlrak/r1mpf1n8/
#search {
position: fixed;
background-color: red;
bottom: 0;
width: 25%;
}
你<LeftNav>
應該包含兩個要素:
overflow-y
設置爲auto
(滾動時間過長)以及導航面板高度的javascript-set height
減去搜索字段高度(包括填充!)position: absolute
,bottom: 0
和width: 100%
,幷包含(或)您#search
場例子this.props.height
設置爲我window.innerHeight
上window
的load
和resize
事件:
<LeftNav>
<div style={{overflowY: 'auto', height: (this.props.height - 50) + 'px'}}>
{menuItems}
</div>
<div style={{position: 'absolute', bottom: 0, width: '100%'}}>
{{searchField}}
</div>
</LeftNav>
你會如何動態確定搜索字段的高度,而不是將其硬編碼爲50? – philcruz
Sligthly offtopic問題:您使用哪種工具來創建屏幕實體模型? – Joerg