2016-02-26 55 views
3

我試圖在<LeftNav>組件內部創建一個粘性頁腳,目前爲止失敗。這是什麼是需要的樣子:如何在LeftNav內創建粘性頁腳?

enter image description here

我已經在搜索領域的包裝使用position: fixed; bottom: 0position: absolute; bottom: 0試過,但是當用戶滾動列表項的搜索欄移動起來。就像這樣:

enter image description here

任何想法如何解決這一問題?

+0

Sligthly offtopic問題:您使用哪種工具來創建屏幕實體模型? – Joerg

回答

1

職位:固定應該工作。如果沒有關於您如何進行網頁設置的更多信息,則很難更具體。看看這個小提琴,看看是否有幫助:

https://jsfiddle.net/kevinlrak/r1mpf1n8/

#search { 
    position: fixed; 
    background-color: red; 
    bottom: 0; 
    width: 25%; 
} 
0

<LeftNav>應該包含兩個要素:

  • 第一個包含的項目和有overflow-y設置爲auto (滾動時間過長)以及導航面板高度的javascript-set height減去搜索字段高度(包括填充!)
  • 第二個是position: absolutebottom: 0width: 100%,幷包含(或)您#search

例子this.props.height設置爲我window.innerHeightwindowloadresize事件:

<LeftNav> 
    <div style={{overflowY: 'auto', height: (this.props.height - 50) + 'px'}}> 
    {menuItems} 
    </div> 
    <div style={{position: 'absolute', bottom: 0, width: '100%'}}> 
    {{searchField}} 
    </div> 
</LeftNav> 
+0

你會如何動態確定搜索字段的高度,而不是將其硬編碼爲50? – philcruz