Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

100vh doesn't take whole screen [closed]

Tags:

css

I want to create a one-scroll-page, like each section is full height from screen.

But when I use 100vh, it doesn't take whole screen height, but more like 95%.

like image 253
C.Ronaldo Avatar asked May 12 '16 15:05

C.Ronaldo


People also ask

Should I use 100vh?

Sure! Applying min-height: 100vh to the body element should do the trick. Here, 100vh means that the initial body height will take 100% of the viewport height, whereas the use of min-height instead of height will let the body element grow even more if necessary.

Does 100vh work on mobile?

Yes, 100vh is 100% of a viewport height (your device), when pure 100% only fill all available parent area (parent block can have e.g. 50px height and it will fill only to this parent height).

What is min height 100vh?

Min height 100vh means the element should occupy the web browser viewport height. This is always 100 percent of the web browser's viewport height. If there is more content, the element will stretch more than the viewport's height, which is a code example that will clear things up.

How do I get divs to open full screen?

position:absolute You can also use position absolute as well as set all the viewport sides (top, right, bottom, left) to 0px will make the div take the full screen.


1 Answers

Adding the code below to your CSS should fix it:

html,body{
margin:0;
}

This is caused by the default margin being 8px so redefining it using CSS will correct it.

Illustration with margin Set:

#Orange{
  height:100vh;
  width:100vw;
  background:orange;
}
body{
  margin:0;
  padding:0;
}
<div id="Orange"></div>

Without the margin:0 adjustment:

#Orange{
  height:100vh;
  width:100vw;
  background:orange;
}
body{
  padding:0;
}
<div id="Orange"></div>

EDIT

Adding this code should adjust the margins for your container.

.container-fluid{
    margin-top: 0;
    margin-bottom: 0;
}
like image 64
codefreaK Avatar answered Sep 28 '22 03:09

codefreaK