div高度100% [英] div height 100 percent

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

问题描述

<img id='imgT' src="...">

<div id="divL"></div>
<div id="divR"></div> 

css

body{
    max-width:1024px;
}
#imgT{
    width:100%;
    border:thin solid blue;
    display:block;
}
#divL{
    width:20%;
    height:100px;  // I need 100%
    background:#008080;
    float:left;
}
#divR{
    width:80%;
    height:100px;  // I need 100%
    background:blue;
    float:left;
}

fiddle is 这里

fiddle is here

那么,如何让两个div高度100%,即从图片底部到页面底部。 p>

So, how can I make the two divs height 100 percent, i.e. from the bottom of image to the bottom of page.

推荐答案

您需要设置 html body 更改为100%。 可以设置元素的高度为100%。

You need to set the height of html and body to 100% too before. Then you can set your element height 100%.

body, html {
    height: 100%;
}

#divL, #divR {
    height: 100%;
}

更新了小提琴。

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

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