2016-06-28 9 views
1

私は私のナビゲーションバーが固定やろうとしているが、それは私がCSSにposition:fixedを追加するときnavbarの操作方法を修正しましたか?

.grid__header { 
position:fixed; 
min-height: 164px; 
height: 164px; 
width:100%; 
display: -webkit-flex; 
display: flex; 
background: transparent; 
-webkit-flex-direction: row; 
-ms-flex-direction: row; 
flex-direction: row; 
-webkit-justify-content: space-between; /* Safari 6.1+ */ 
justify-content: space-between; 
} 

左コンテナクラスが.grid__header wihin動作しませんが流れます。それを修正するには?

Codepen code

答えて

4

あなたは、それはそれの中心にするために、左に移動しますposition:fixedを追加lefttopからそのpostionを指定する必要がPosition.grid__header

position:fixed; left:0; right:0;

+0

'左:0;'と '右:0;'十分です。左右に余白を設定する必要はありません。 –

+0

はい、余白は必要ありません。更新 –

+0

はい、そうです!ありがとう。しかし、z-indexをどうすればいいですか(メニューを開くと - 閉じるボタンが機能しません)? – Slip

2

に次のCSSを追加します。

.grid__header { 
 
    position:fixed; 
 
    left:0; right:0; 
 
    min-height: 164px; 
 
    height: 164px; 
 
    width:100%; 
 
    display: -webkit-flex; 
 
    display: flex; 
 
    /* background: transparent; */ 
 
    
 
    background:#ccc; 
 
    -webkit-flex-direction: row; 
 
    -ms-flex-direction: row; 
 
    flex-direction: row; 
 
    -webkit-justify-content: space-between; /* Safari 6.1+ */ 
 
    justify-content: space-between; 
 
    } 
 
/*##setting height just for display##*/ 
 
body{height:1500px;margin:0;padding:0;}
<header class="grid__header"></header>

関連する問題