浮动div CSS下的页边空白 [英] margin-top under a floated div css

查看:178
本文介绍了浮动div CSS下的页边空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在float:right div下有一个div.由于某些原因,顶边距不能应用于第一格.这是CSS

I have a div under a float:right div. For some reason, the top margin cannot be applied to the first div. here is the css

#over{
  width:80%;
  float:right;
  color:#e68200; 
 }

#under{
  clear:both;
  background:url(../images/anazitisi.png) no-repeat;  
  margin:10px auto; /*does not work!!!*/
  width:95px;
  height:20px;
 } 

有人知道发生了什么吗?

does anyone know what's going on?

推荐答案

浮动内容是从常规布局中浮动出来的,因此通常不会影响未像它们一样浮动的其他内容.当然,在不同的浏览器中,浮动行为会有所不同,但这是总的思路.

Floated things are kind of floated out of the normal layout, so generally don't affect other things that aren't floated like them. Of course the float behaviour in different browsers differs, but that's the general idea.

在浮动div之后,您需要一些东西(例如一个空的div)来清除浮动(具有style ="clear:both;").

After the floated div you'd need something (like an empty div) that will clear the float (has style="clear:both;").

但是,就像我说的那样,浏览器的行为仍然会变化,然后决定应该从何处计算利润.当然有解决方法. 有关详情,请参见此页面.

However, like I said, browser behaviour will still vary, on where it then decides the margin should be counted from. There are of course workarounds for that. See this page for more on that.

这篇关于浮动div CSS下的页边空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆