2014-09-22 84 views
0

我有一個width: 100%;的sitewrapper,它被推到右邊,如果點擊一個特定的按鈕,會帶來一個position: fixed;邊欄。這工作相當不錯,我唯一的問題是,如果站點加載滾動條,它會在固定位置div之間創建一個裂縫。你有沒有人有建議?滾動條裂縫固定位置側邊欄的佈局

#right_sidebar { 
    width: 160px; 
    height: 100%; 
    background-color: #ffb005; 
    position: fixed; 
    right: -160px; 
} 

和點擊:

$('#button').click(function() { 
    $right_sidebar.animate({right: 0}, transDelay); 
    $outer_wrapper.animate({marginLeft: -160}, transDelay); 
}); 

編輯: FIDDLE HERE,請按綠色背景。

+0

可以試一下提供一些更多的代碼(行動中的問題):) – 2014-09-22 14:22:17

+0

@theScorpion謝謝,在這裏你去http://jsfiddle.net/o56jt2fe/1/ – supersize 2014-09-22 14:29:18

+0

你什麼意思是'一個破解'? – 2014-09-22 14:45:30

回答

0

我爲你固定它。

這裏是fiddle

添加該做的伎倆:

body, html { 
    height: 100%; 
    margin: 0; 
    outline: 0; 
} 
+0

不幸的是它不適用於我的情況。 – supersize 2014-09-22 15:15:52

+0

@supersize也許這樣? http://jsfiddle.net/o56jt2fe/4/ – 2014-09-22 16:09:32

0

似乎是100%的寬度是問題 - 試試這個:如果你可以

<div id="outer_wrapper"> 
    <div id="right_sidebar">dfsdf</div> 
</div> 

#outer_wrapper { 
/* width: 100%; */ 
    min-height: 100%; 
    background-color: green; 
} 
#right_sidebar { 
    position: fixed; 
    right: -160px; 
    width: 160px; 
    min-height: 100%; 
    background-color: red; 
}