Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set div height to 100% of user's monitor resolution?

height: 100% in CSS obviously doesn't work. So is there any other CSS or JavaScript/jQuery solutions to this problem? Please advise.

like image 774
Jacob Avatar asked Mar 03 '11 03:03

Jacob


People also ask

What does height 100% do CSS?

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.

How do you make a Div screen full width?

The width property is used to fill a div remaining horizontal space using CSS. By setting the width to 100% it takes the whole width available of its parent. Example 1: This example use width property to fill the horizontal space. It set width to 100% to fill it completely.

What is the width and height of full screen?

The most universally used ratios are 16:9—known as the Widescreen, and 4:3 –commonly referred to as Full Screen. The 16:9 ratio is a wide rectangular shape, whereas the 4:3 ratio is a narrower rectangle, closer to a square.


1 Answers

No Javascript required,becouse CSS3 has some new values for sizing things relative to the current viewport size: vw, vh, and vmin

1vw = 1% of viewport width
1vh = 1% of viewport height
1vmin = 1vw or 1vh, whichever is smaller
1vmax = 1vw or 1vh, whichever is larger

so you can write it on your style :

#contentDiv {
  height: 100vh;
}
like image 141
saghar.fadaei Avatar answered Sep 27 '22 18:09

saghar.fadaei