Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make image fit full screen without scroll bars

I need to make a header image full screen. I tried this:

<div class="wrapper">
   <img src="images/image1.jpg" class="img-responsive" alt="Responsive image">
</div>

But here is the picture:

enter image description here

Somehow window still need to scroll down as you can see, how can i fix this, to fit in screen?

like image 558
McLaren Avatar asked Sep 10 '15 17:09

McLaren


People also ask

How do we get the width of a webpage with or without scrollbars?

To get the width of the scrollbar, you use the offsetWidth and clientWidth of the Element : The offsetWidth returns the width of the Element in pixels including the scrollbar. The clientWidth returns the with of the Element in pixels without the scrollbar.


2 Answers

Try this:

.img-responsive { background-size: 100%; }

OR

.img-responsive { background-size: cover; }

OR (based on revised question)

Add this to body:

overflow: hidden;
like image 119
Michael Benjamin Avatar answered Oct 21 '22 22:10

Michael Benjamin


Instead of img tag, use background-image for fullscreen image.

<header>
  <div class="menu_area">...</div>
</header>


html, body, header {
    height: 100%;
}
header {
    background-image: url('images/image1.jpg');
    background-size: cover;
}
like image 28
Praseetha KR Avatar answered Oct 21 '22 21:10

Praseetha KR