2016-09-24 7 views
1

私は周りを見て、どのように水平に私の固定ナビゲーションバーの中心を見つけることができません。固定ナビゲーションバーをどのように水平に配置するのですか?

もしあなたが私に方法の説明と理由を説明することができます。

ありがとうございました。

#nav { 
 
    list-style: none; 
 
    position: fixed; 
 
    margin-top: -10px; 
 
    width: 100%; 
 
    font-family: Product Sans; 
 
    font-size: 0; 
 
} 
 
#nav li { 
 
    width: 200px; 
 
    height: 50px; 
 
    display: inline-block; 
 
    text-align: center; 
 
    padding-top: 5px; 
 
    background-color: white; 
 
    font-size: 30px; 
 
}
<ul id="nav"> 
 
    <li>stack</li> 
 
    <li>over</li> 
 
    <li>flow</li> 
 
</ul>
あなたは、UL

内のli項目を中央揃えする必要が

答えて

1

ので、CSSは

<style> 

#nav{ 
    list-style: none; 
    position: fixed; 
    margin-top: -10px; 
    width: 100%; 
    font-family: Product Sans; 
    font-size: 0; 
    text-align:center; 
    padding-left:0px; 
} 
#nav li{ 
    width: 200px; 
    height: 50px; 
    display: inline-block; 
    text-align: center; 
    padding-top: 5px; 
    background-color: white; 
    font-size: 30px; 
} 


</style> 

ことそしてそのままHTMLを維持します

0

を追加するだけです〜#nav、このように:

<style> 
#nav{ 
    list-style: none; 
    position: fixed; 
    margin-top: -10px; 
    width: 100%; 
    font-family: Product Sans; 
    font-size: 0; 
    text-align: center; /* <--- */ 
} 
</style> 
関連する問題