2012-12-22 26 views
1

如何获得“运行”按钮下面的div?如何获得div浮动下的按钮元素?

enter image description here

下面是代码:http://jsbin.com/ehurit/10/edit

相同的代码下面复制粘贴。

<!DOCTYPE html> 
<html> 
<head> 
    <style> 
    div.boxes { background:yellow; border:1px solid #AAA; width:80px; height:80px; margin:0 5px; float:left; } 
    div.colored { background:green; } 
    .clearfix:after { 
    content: "."; 
    display: block; 
    clear: both; 
    visibility: hidden; 
    line-height: 0; 
    height: 0; 
} 

.clearfix { 
    display: inline-block; 
} 
    </style> 
</head> 
<body> 
    <div class="boxes"></div> 
    <div class="boxes" id="mover"></div> 
    <div class="boxes"></div>  
    <button class="clearfix" id="run" >Run</button> 
</body> 
</html> 

回答

3

.clearfix CSS类尝试display: blockclear: both

Demo

更新:我刚刚检查了一遍,你应该设置clearfix周围的浮动的div像这样:http://jsfiddle.net/dC7GL/1/

+0

感谢贺联的按钮。 _ – SunnyShah

3

改变你的风格

.clearfix { 
     clear:both; 
} 

然后上面的按钮添加一个div标签并应用明确修复的风格会向下推,下面的框中

<div class="clearfix"></div> 
    <button id="run" >Run</button>