2013-03-26 81 views
-1

我不明白,为什么我的浮动不起作用。有site - 正如你所看到的,浮动不想工作。它有什么问题?漂浮在身体

+0

嗨。对不起,你想要这个块的地方?因为我可以在容器的右角看到它 – 2013-03-26 11:32:41

+1

使用'clear:both'删除块。 – 2013-03-26 11:33:26

回答

0

它的工作原理。它在<div id="content">的父级上下文中是浮动的。 你需要的是浮动离开<div class="side_bar">之前把它(在HTML代码),就像这样:

<div id="content"> 
    <div class="news_block"> 
     the floating to the right side - don't want to work 
    </div> 
    <div class="side_bar"> 
     sidebar 
    </div> 
</div> 

OR,例如,如果你的脚本需要,你想换左边,你想要的一切到Side_bar DIV,这是唯一一个CSS左边浮动的人。也许你没有注意到它,但你必须:

<div id="content"> 
    <div class="side_bar"> <!-- floats left --> 
     sidebar 
    </div> 
    <div> facebook thing </div> <!-- doesn't float --> 
    <div> ads </div> <!-- doesn't float --> 
    <div> whatever </div> <!-- doesn't float --> 
    <div class="news_block"> <!-- floats right--> 
     the floating to the right side - don't want to work 
    </div> 
</div> 

你不能指望已经float定义正确浮动两个div,当你有非浮动元素在他们之间。

+0

对不起,我没有得到:( – 2013-03-26 11:46:19