2017-03-18 34 views
0

我目前正在爲我的網站設計導航欄,我遇到了Firefox中的問題。我的標識位於左側,導航內容位於右側,但整個導航內容正在從導航div中移除(僅限於Firefox)。我能做些什麼來解決它?火狐推送內容時,浮動權利

火狐: http://i.cubeupload.com/OoAJIe.png

鉻: http://i.cubeupload.com/QXo2KS.png

這裏是我的HTML:

<div class="nav" id="nav"> 
    <div class="nav_content"> 

     <ul> 
     <li class="logo"><a href="index.php"><img src="images/Spendr.png" /></a></li> 

     <li class="tab btn"><a href="panel/index.php"><button>Kurv: 0</button></a></li> 
     <li class="tab txt"><a href="#udbetaling">Nye varer</a></li> 
     <li class="tab txt"><a href="#features">Udsalg</a></li> 
     <li class="tab txt" id="kategorierMenu"><a>Kategorier</a></li> 
     </ul> 

    </div> 
    </div> 

這裏是我的CSS:

.nav { 
    width: 100%; 
    background: #262626; 
    transition: background 0.5s, border 0.5s, color 0.5s, height 0.5s, padding-top 0.3s, opacity 0.5s; 
    position: fixed /*fixed*/; 
    z-index: 999; 
    height: 71px; 
    float: left; 
} 

.nav_content { 
    max-width: 1150px; 
    width: 90%; 
    height: 100%; 
    background: none; 
    margin: 0 auto; 
    white-space: nowrap; 
} 

.nav ul li, .nav ul li a { 
    list-style: none; 
    text-decoration: none; 
    display: inline-block; 
} .nav .tab{ 
    float: right; 
    font-family: DroidSans, sans-serif; 
    font-size: 16px; 
    color: #FFFFFF; 
    text-decoration: none; 
    transition: color 0.3s; 
} 

.txt a { 
    float: right; 
    font-family: DroidSans, sans-serif; 
    font-size: 16px; 
    color: #FFFFFF; 
    text-decoration: none; 
    transition: color 0.3s; 
    height: 100%; 
    padding-top: 26px; 
    box-sizing: border-box; 
    transition: background 0.3s; 
} 

.txt a:hover { 
    cursor: pointer; 
    background: #1A1A1A; 
} 
.nav .tab { border-radius: 3px; } 
.nav .txt a { 
    padding-left:18px; 
    padding-right: 18px; 
} 

.logo img { 
    height: 36px; 
    width: auto; 
    margin-top: 18px; 
    float: left; 
} 
+0

嘗試改變'.logo IMG {邊距}''到填充-top' –

回答

0

既然你浮動.tab元素的權利,添加.logo { float: left; },這將使列表項都浮動在菜單的任一側。

.nav { 
 
    width: 100%; 
 
    background: #262626; 
 
    transition: background 0.5s, border 0.5s, color 0.5s, height 0.5s, padding-top 0.3s, opacity 0.5s; 
 
    position: fixed/*fixed*/ 
 
    ; 
 
    z-index: 999; 
 
    height: 71px; 
 
    float: left; 
 
} 
 

 
.nav_content { 
 
    max-width: 1150px; 
 
    width: 90%; 
 
    height: 100%; 
 
    background: none; 
 
    margin: 0 auto; 
 
    white-space: nowrap; 
 
} 
 

 
.nav ul li, 
 
.nav ul li a { 
 
    list-style: none; 
 
    text-decoration: none; 
 
    display: inline-block; 
 
} 
 

 
.nav .tab { 
 
    float: right; 
 
    font-family: DroidSans, sans-serif; 
 
    font-size: 16px; 
 
    color: #FFFFFF; 
 
    text-decoration: none; 
 
    transition: color 0.3s; 
 
} 
 

 
.txt a { 
 
    float: right; 
 
    font-family: DroidSans, sans-serif; 
 
    font-size: 16px; 
 
    color: #FFFFFF; 
 
    text-decoration: none; 
 
    transition: color 0.3s; 
 
    height: 100%; 
 
    padding-top: 26px; 
 
    box-sizing: border-box; 
 
    transition: background 0.3s; 
 
} 
 

 
.txt a:hover { 
 
    cursor: pointer; 
 
    background: #1A1A1A; 
 
} 
 

 
.nav .tab { 
 
    border-radius: 3px; 
 
} 
 

 
.nav .txt a { 
 
    padding-left: 18px; 
 
    padding-right: 18px; 
 
} 
 

 
.logo img { 
 
    height: 36px; 
 
    width: auto; 
 
    margin-top: 18px; 
 
    float: left; 
 
} 
 

 
.logo { 
 
    float: left; 
 
}
<div class="nav" id="nav"> 
 
    <div class="nav_content"> 
 

 
    <ul> 
 
     <li class="logo"> 
 
     <a href="index.php"><img src="images/Spendr.png" /></a> 
 
     </li> 
 

 
     <li class="tab btn"><a href="panel/index.php"><button>Kurv: 0</button></a></li> 
 
     <li class="tab txt"><a href="#udbetaling">Nye varer</a></li> 
 
     <li class="tab txt"><a href="#features">Udsalg</a></li> 
 
     <li class="tab txt" id="kategorierMenu"><a>Kategorier</a></li> 
 
    </ul> 
 

 
    </div> 
 
</div>

您還可以更改菜單爲flex佈局和使用auto緣上.logo的元素分開。

.nav { 
 
    width: 100%; 
 
    background: #262626; 
 
    transition: background 0.5s, border 0.5s, color 0.5s, height 0.5s, padding-top 0.3s, opacity 0.5s; 
 
    position: fixed/*fixed*/ 
 
    ; 
 
    z-index: 999; 
 
    height: 71px; 
 
    float: left; 
 
} 
 

 
.nav_content { 
 
    max-width: 1150px; 
 
    width: 90%; 
 
    height: 100%; 
 
    background: none; 
 
    margin: 0 auto; 
 
    white-space: nowrap; 
 
} 
 

 
.nav ul li, 
 
.nav ul li a { 
 
    list-style: none; 
 
    text-decoration: none; 
 
    display: inline-block; 
 
} 
 

 
.nav .tab { 
 
    float: right; 
 
    font-family: DroidSans, sans-serif; 
 
    font-size: 16px; 
 
    color: #FFFFFF; 
 
    text-decoration: none; 
 
    transition: color 0.3s; 
 
} 
 

 
.txt a { 
 
    float: right; 
 
    font-family: DroidSans, sans-serif; 
 
    font-size: 16px; 
 
    color: #FFFFFF; 
 
    text-decoration: none; 
 
    transition: color 0.3s; 
 
    height: 100%; 
 
    padding-top: 26px; 
 
    box-sizing: border-box; 
 
    transition: background 0.3s; 
 
} 
 

 
.txt a:hover { 
 
    cursor: pointer; 
 
    background: #1A1A1A; 
 
} 
 

 
.nav .tab { 
 
    border-radius: 3px; 
 
} 
 

 
.nav .txt a { 
 
    padding-left: 18px; 
 
    padding-right: 18px; 
 
} 
 

 
.logo img { 
 
    height: 36px; 
 
    width: auto; 
 
    margin-top: 18px; 
 
    float: left; 
 
} 
 

 
.nav ul { 
 
    display: flex; 
 
} 
 

 
.logo { 
 
    margin-right: auto; 
 
}
<div class="nav" id="nav"> 
 
    <div class="nav_content"> 
 

 
    <ul> 
 
     <li class="logo"> 
 
     <a href="index.php"><img src="images/Spendr.png" /></a> 
 
     </li> 
 

 
     <li class="tab btn"><a href="panel/index.php"><button>Kurv: 0</button></a></li> 
 
     <li class="tab txt"><a href="#udbetaling">Nye varer</a></li> 
 
     <li class="tab txt"><a href="#features">Udsalg</a></li> 
 
     <li class="tab txt" id="kategorierMenu"><a>Kategorier</a></li> 
 
    </ul> 
 

 
    </div> 
 
</div>