2014-01-16 22 views
0

我想把我的標誌浮在標題的左邊,但它根本不會浮動到左邊。我真的很感激,如果有人能指出我的錯誤,因爲我是新來的CSS。徽標不會在標題中左移嗎?

這是我的網站,如果你想看到我的問題現場:http://cashski.com/

這裏是我的HTML代碼:

<div id="navigation"> 
    <div class="center_navigation"> 
     <a href="contact.php">Contact</a> 
     <a href="buy-instagram-followers.php">Instagram Followers</a> 
     <a href="buy-instagram-photo-likes.php">Instagram Photo Likes</a> 
     <a href="index.php"><img src="img/logo.png" /></a> 
    </div> 
</div> 

這裏是我的CSS代碼:

body { 
    padding: 0px; 
    margin: 0px; 
    font-family: Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif; 
} 
#navigation{ 
    width: 100%; 
    height: 50px; 
    margin: 0px auto; 
    position: relative; 
    background-color: #2d5b89; 
    border-bottom: 1px solid #244a75; 
} 
.center_navigation { 
    width: 960px; 
    height: 50px; 
    margin:0px auto; 
    font-size: 16px; 
} 
.center_navigation a { 
    padding: 10px 0 10px 30px; 
    float: right; 
    margin-top: 4px; 
    color: #babcc5; 
    text-decoration: none; 
} 
.center_navigation a:hover { 
    color: white; 
} 
.center_navigation a img { 
    float: left; 
} 
+0

這是你的問題:'.center_navigation一個{浮動:權; }' – melancia

回答

4

的問題是你的所有anchor標籤是float:right和你的圖像是在anchor標籤,所以使img float:left不變很多。

所以你要麼把圖像的容器上的樣式即。錨標記這樣

<a href="index.php" style="float: left;"> 
    <img src="img/logo.png"> 
</a> 

,或者如果你的形象總是在最後一個錨標記,那麼你也可以使用這個

.center_navigation a:last-child{ 
    float: left; 
} 

Js Fiddle Demo

+0

好的,謝謝你的幫助! – user3167464

+0

提及':last-child'的+1 – melancia