Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

div height 100 percent

Tags:

html

css

<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 here

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

like image 707
qadenza Avatar asked Oct 01 '13 17:10

qadenza


People also ask

How do you make a div 100% height?

Syntax: To set a div element height to 100% of the browser window, it can simply use the following property of CSS: height:100vh; Example: HTML.

How do I make my height 100% in HTML?

With no height value provided for the HTML element, setting the height and/or min-height of the body element to 100% results in no height (before you add content).

What does CSS height 100% do?

height: 100% gives the element 100% height of its parent container. height: auto means the element height will depend upon the height of its children.


2 Answers

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%;
}

Updated fiddle.

like image 117
federico-t Avatar answered Oct 18 '22 04:10

federico-t


There are a few options you may find useful:

vh (viewport height) vw (viewport width) vmin (viewport minimum length) vmax (viewport maximum length) Now, let’s have a look at a real example. Imagine you want to create a website with two sections, each one of them with the size of the browser window.

Here’s just a simplified code example of the HTML:

<div id="welcome">
   your content on screen 1
</div>

<div id="projects">
   your content on screen 2
</div>

and here’s the CSS using vh:

div#welcome {
    height: 100vh;
    background: black;
}

div#projects {
    height: 100vh;
    background: yellow;
}

You can see more in:

http://stanhub.com/how-to-make-div-element-100-height-of-browser-window-using-css-only/

like image 33
anayarojo Avatar answered Oct 18 '22 05:10

anayarojo