0

We are using bootstrap library for styling. We have a div and we want the div to take the height of the screen. I do not want to set min or max height.

I can set the height through javascript but I am just curious if I can force the div to take height of the screen through CSS. Do we have any option apart from using media query?

SharpCoder
  • 18,279
  • 43
  • 153
  • 249

3 Answers3

5

You can also use vh. vh is viewport height. You can find more about it here

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
Aakash Aggarwal
  • 306
  • 2
  • 9
1

Please check if this is what you want.

html,
body {
  height: 100%;
}
div {
  height: 100%;
}
<div>
  <h1> Hello World </h1>
</div>

JSFIDDLE

Avijit Kumar
  • 538
  • 2
  • 9
0

Yes, you can do by using position. Say you have the div as .mask:

.mask {
  position: absolute;
  width: 100%;
  height: 100%;
}
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252