2017-05-22 168 views
0

我有導航欄和材質設計主題,但存在滾動水平時無法處理的問題。水平滾動時的固定寬度

這些是問題的圖片; enter image description here

當我嘗試水平滾動時,這可怕的視覺出來; enter image description here

這裏是導航欄的CSS代碼;

我創建的紅圈就是問題所在。我想要的是,當我滾動水平時,該導航欄應保持固定而不滾動。這可能嗎?

感謝

+0

請張貼您的代碼。謝謝! – trav

+0

發表!謝謝! @trav –

+0

感謝您的努力,但如果可能的話,請在這裏發佈原始代碼。您也可以將代碼複製並粘貼到[jsfiddle](http://jsfiddle.net)中,然後在此處發佈。 – trav

回答

1

嘗試加入這個CSS

body{ 
    overflow-x:hidden; 
} 

.body-of-content{ 
    overflow-x:auto; 
    max-width:100%; 
} 

下面是一個小提琴顯示一個用例

https://jsfiddle.net/12md1fqh/

代碼片段

body{ 
 
    overflow-x:hidden; 
 
} 
 
.header{ 
 
    width:100%; 
 
    height:50px; 
 
    background-color: black; 
 
    color:white; 
 
    text-align:center; 
 
    font-size:2em; 
 
} 
 
.data{ 
 
    width:200%; 
 
    height:50px; 
 
    background-color: #eee; 
 
} 
 

 
.body-of-content{ 
 
    max-width:100%; 
 
    height:500px; 
 
    background-color: green; 
 
    overflow-x:auto; 
 
}
<div class="header"> 
 
    Header 
 
</div> 
 

 
<div class="body-of-content"> 
 
<div class="data"> 
 
I am scrollllllllllllllllllllllllllllllllllllableeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee !! 
 
</div> 
 
</div>

+0

謝謝!這很好用! –