2013-06-25 19 views
1

我目前有這個網站http://rinique.com/。但是,如果在iPhone和iPad等移動設備上查看,則導航欄和徽標不再位於中心位置。部分原因是我現在強迫它「左:150px」;使其看起來像中心。如何在wp中動態中心導航欄

有什麼辦法可以動態強制它居中?下面是導航欄CSS的一個片段。

#header #navigation { 
    display: block !important; 
    width: 100%; 
    margin-top: .382em; 


    } 
    #header #navigation ul.nav { 
    float: left; 
    position: relative; 
    width: 100%; 
    left: 150px; 
+1

'修復寬度+保證金:汽車;'這就是你所需要的,如果它是水平居中 –

+0

嘗試把剩下%而不是硬編號碼。 –

回答

0

應用此CSS

#header #navigation{ 
    text-align:center; // add this line 
    overflow:hidden; // add this line 
    float: center; // remove this line 

    } 
    #header #navigation ul.nav{ 
    display:inline-block; // add this line 
    vertical-align:top; // add this line 
    float:left: // remove this line 
    width: 100%; // remove this line 
    left: 150px; // remove this line 
    } 
+0

謝謝!我不得不增加寬度:100%;到#header #navigation,它會很好地工作 –

0

試試這個

#header #navigation ul.nav { 
    padding: 0; 
    float: left; 
    position: relative; 
    left: 150px; 
    display: inline-block; /*added*/ 
} 

#header #navigation { 
    border: none; 
    background: black; 
    -webkit-box-shadow: none; 
    box-shadow: none; 
    width: auto; 
    text-align: center; /*added*/ 
}