Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a div cover the whole screen

I have a question.

I got this so far: enter image description here

I basically want the highlighted div to cover your device screen no matter how big the device screen is. now i see 2 different divs when i open this on my phone. i only want to see the one that is highlighted. How do I achieve this?

Thanks in advance, kevin

like image 966
Kevin Avatar asked May 18 '16 09:05

Kevin


People also ask

How do I make a div cover the whole screen width?

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.

How do you make a full page container?

Firstly, you will want to drag a Container Element onto your page. From the right-hand menu of the editor, you will notice that there is a "Full Width" toggle. Toggling this will set this Container Element to full width on your page.

How do I make div full screen on button click?

You'll want a fixed position element at 100% width and height , if you don't have a background color or image you'll be able to click through it. Set z-index higher then all other elements to ensure it is at the front if you need that.


4 Answers

You could use viewport height as your height value:

.main {
    height: 100vh;
    background-color: green;
}
<div class="main">
  CONTENT
</div>

Using height: 100vh means the element in question always be 100% height of the viewport a user / devie has.

More info: https://web-design-weekly.com/2014/11/18/viewport-units-vw-vh-vmin-vmax/

like image 103
David Wilkinson Avatar answered Oct 25 '22 14:10

David Wilkinson


You can probably do that by setting the position of the div that you want to make fullscreen, to absoluteand then apply the below CSS.

top:0;
left:0;
bottom:0;
right:0;
height:100%;
width:100%;

Thus, the final css would be as follows

.fullscreen{
    position:absolute;
    top:0;
    left:0;
    bottom:0;
    right:0;
    height:100%;
    width:100%;
}
like image 30
saugandh k Avatar answered Oct 25 '22 15:10

saugandh k


You can use position: absolute; or position: fixed.
Use absolute for just making it cover the whole page.
Use fixed to make it nailed in a default position. If u use fixed, even though your page is more than 100% you cannot scroll down to see any other things.

CSS

div.any {
   position: absolute; /*position: fixed;*/
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   /*You can add anything else to this like image, background-color, etc.*/
}

HTML

<div class="any"></div>
like image 4
Advaith Avatar answered Oct 25 '22 15:10

Advaith


.video-container {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    object-fit: fill;
}

.video-container video {
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
like image 1
Abhishek Meharia Avatar answered Oct 25 '22 14:10

Abhishek Meharia