19

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

Kevin
  • 930
  • 3
  • 13
  • 34

4 Answers4

30

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/

David Wilkinson
  • 5,060
  • 1
  • 18
  • 32
6

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%;
}
saugandh k
  • 1,018
  • 1
  • 8
  • 14
3

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 you 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>
Yves M.
  • 29,855
  • 23
  • 108
  • 144
Advaith
  • 2,490
  • 3
  • 21
  • 36
1
.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%);
}
Paul Roub
  • 36,322
  • 27
  • 84
  • 93