2015-02-10 171 views
0

我有一個橫跨五個頁面寬度水平滾動的網站。我希望頁眉在頁面水平滾動時保持固定在相同的位置。在Safari中,標題與CSS規則保持一致,「position:fixed」。但是,在Firefox,Chrome和IE中,標題會隨頁面一起滾動。有沒有更容易的方法比從每個頁面的包裝中拉出標題?代碼很複雜,所以我想避免將它拉到外面。CSS標頭固定位置

<div id="page1"> 
    <div class="header"></div> 
</div> 
<div id="page2"> 
    <div class="header"></div> 
</div> 
<div id="page3"> 
    <div class="header"></div> 
</div> 
.header { 
    width:100%; 
    height:110px; 
    background-color: rgba(43, 77, 105, .6); 
    z-index: 10; 
    position: fixed; 
    top:0; 
} 
+1

你試過把左:0?可能是有用的 – 2015-02-10 15:06:00

+0

它在我的Firefox上使用這個小提琴工作http://jsfiddle.net/oc8ywqg3/ – nanndoj 2015-02-10 15:07:53

+0

@PravinVaichal這樣做了。把它作爲答案,我會給你信用。 – 2015-02-10 15:09:13

回答

0

你可以嘗試添加left:0屬性.header類來解決這個問題

編碼快樂:)