18

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
  • 920
  • 3
  • 12
  • 32

4 Answers4

25

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
  • 4,940
  • 1
  • 20
  • 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
  • 958
  • 1
  • 7
  • 14
4

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>
Advaith
  • 2,340
  • 3
  • 19
  • 34
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
  • 35,848
  • 27
  • 79
  • 88