2013-01-31 110 views
0

http://tinkerbin.com/OREvWmf6修復DIV向右

什麼我嘗試做的,就是確保我的標誌停留在右側...

所以鏈接將包裹在左邊。但相反,他們推動了標誌。

頂部圖像是理想的,底部是我得到的。 enter image description here

<div style="width: 100%; height: 75px; background:#B9C7D4" > 
     Link 1 
    Link2 
    Link 3 
      Link 1 
    Link2 
    Link 3 
      Link 1 
    Link2 
    Link 3 
      Link 1 
    Link2 
    Link 3 
    <img height=75px style="float:right;" src="http://dogmatic69.com/files/portfolio/image/4f288818-c5a8-4872-a003-06376318cd71/stackoverflow-logo.png" alt=""/> 

</div> 
+1

被盜的clearfix代碼將img移動到鏈接之前。只需將它作爲父div的第一個孩子滑動即可。 –

回答

2

首先把你的形象:

<div style="width: 100%; height: 75px; background:#B9C7D4" > 
    <img height=75px style="float:right;" src="http://dogmatic69.com/files/portfolio/image/4f288818-c5a8-4872-a003-06376318cd71/stackoverflow-logo.png" alt=""/> 

     Link 1 
    Link2 
    Link 3 
      Link 1 
    Link2 
    Link 3 
      Link 1 
    Link2 
    Link 3 
      Link 1 
    Link2 
    Link 3 

</div> 
+2

只是出於好奇,你能解釋爲什麼它以這種方式工作的推理嗎? – iamnotmaynard

0
<img height=75px style="float:right;position:absolute;top:0px;right:0px;" src="http://dogmatic69.com/files/portfolio/image/4f288818-c5a8-4872-a003-06376318cd71/stackoverflow-logo.png" alt=""/> 
1

它會是最簡單的,如果你的結構是這樣:

<div class="wrapper clearfix"> 
    <div class="links"><!-- ul with links or whatever --></div> 
    <div class="logo"><img /></div> 
</div> 

隨着風格:

<style type="text/css"> 
.links { width: 250px; float: left;} 
.logo { width: 75px; float: right; } 
.clearfix:before, 
.clearfix:after { 
    content:""; 
    display:table; 
} 
.clearfix:after { 
    clear:both; 
} 
/* For IE 6/7 (trigger hasLayout) */ 
.clearfix { 
    zoom:1; 
} 
</style> 

注意:從What methods of ‘clearfix’ can I use?