未分类

DIV+CSS笔记

备注:信息基本来自网络

1.div 100%高度问题

以前使用表格很容易的实现100%高度,但是div似乎没有办法实现。其实只要细心就会发现,同样的 Width:100% 是很容易实现的,但是为什么 Height:100% 却不能撑满屏幕,甚至是1px大小。

其实只是容器的高度还没有生成而已,CSS都是在HTML代码的最上面,整个容器中的内容还没有完全载入,所以也不能获得页面的正常高度,所以 100%=1px 它是成立的!

解决的办法倒是很简单就是:
html, body{ height:100% }    html属性是FF所用的

将容器在页面载入之初就撑满这个浏览器,后续百分比设定的高度就会按照整个浏览器的高度来计算了,不然还是100%=1px。

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*Required Fields