多垂直100%高度&宽度div [英] Multiple vertical 100% height & width divs

查看:87
本文介绍了多垂直100%高度&宽度div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建多个div与100%两个宽度&高度,但保持失败可悲。示例:

I'm trying to create multiple divs with 100% both width & height, but keep failing miserably. Example:

<html>
<body>
    <div id="wrapper">
        <div id="1">100% height & width, all you can see when opening this file!</div>
        <div id="2">I'll be 100% when you've scrolled #1 out of the window!</div>
    </div>
</body>
</html>

这个解决方案的css是什么?

What is the css for this solution? I can't seem get it working.

推荐答案

解决方案是首先重置默认值 margin padding

The solution is first reset default values for margin and padding:

* {
  margin:0;
  padding:0;
}

其次使您的 html body 是100%:

Second make your html and body be the 100%:

html, body {
   height:100%;
}

然后您的div维度:

#wrapper, #one, #two {
   width:100%;
   height:100%;
}

第一个字符

演示 http://jsfiddle.net / 3fCZg /

The demo http://jsfiddle.net/3fCZg/

这篇关于多垂直100%高度&amp;宽度div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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