Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fit the webpage exactly the screen size without scrolling?

Tags:

html

css

I am new to css and I am finding some difficulty in setting my webpage to fit exactly the screen size but it doesn't fit and a scroll bar occurs. I have tried all the ways mentioned here But none of them works. My web page looks more or less like this. When i used

html{
height: 100vh;
}

body{
    width: 100%;
    height: 100vh;
    background-color: #ffffff;
    font-family: gothambook;
    position: fixed;
    top: 0;
    bottom: 0;
    }

The scroll bar didn't occur but the content went below the screen and was not visible

like image 214
Naveen Kumar Avatar asked Dec 22 '16 02:12

Naveen Kumar


People also ask

How do I make my website fit my screen size in HTML?

You should set body and html to position:fixed; , and then set right: , left: , top: , and bottom: to 0; . That way, even if content overflows it will not extend past the limits of the viewport. Caveat: Using this method, if the user makes their window smaller, content will be cut off.


1 Answers

html {}
body {
    height: 95vh;
}

vh stands for View Height and so 97vh is 97% the View/Browser's height.

https://css-tricks.com/fun-viewport-units/

For some reason 100vh makes it scroll a little.

like image 158
Gene Avatar answered Sep 21 '22 19:09

Gene