position:相对离开一个空格 [英] position:relative leaves an empty space

查看:133
本文介绍了position:相对离开一个空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码在这里: http://lasers.org.ru/vs/example.html p>

如何删除主块下的空白空间(#page)?

解决方案

p>那么,不要使用相对定位。元素仍然占用了它最初在使用相对定位时的空间,你不能去掉它。例如,您可以使用绝对定位,或使元素彼此浮动。



我在布局中玩了一些,我建议您更改这三个规则:

  #layout {width:636px; margin:0 auto; } 
#menu {position:absolute; width:160px; margin-left:160px; }
#page {width:600px; padding:8px 16px; border:2px solid#404241; }


Code is here: http://lasers.org.ru/vs/example.html

How to remove an empty space under main block (#page)?

解决方案

Well, don't use relative positioning then. The element still takes up space where it originally was when using relative positioning, and you can't get rid of that. You can for example use absolute positioning instead, or make the elements float beside each other.

I played around with the layout a bit, and I suggest that you change these three rules to:

#layout { width: 636px; margin: 0 auto; }
#menu { position: absolute; width: 160px; margin-left: 160px; }
#page { width: 600px; padding: 8px 16px; border: 2px solid #404241; }

这篇关于position:相对离开一个空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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