-2

This CSS rule not working..

#wrapper{
   height:100%;
   width:100%;
   background-color: aliceblue;
}

The wrapper does not take the full height of the page..

Paulie_D
  • 107,962
  • 13
  • 142
  • 161

3 Answers3

0

Just try like below it will be work for your issue.

First, pick the div which was you want to make 100% height of your any device and then apply CSS like below.

.wrapper {
    height: 100vh;
}

For make your section or div height same as well as your device height you have to use VH, It's called viewport height.

Vimal Raiyani
  • 174
  • 2
  • 11
0

I am trying to create a div for which I set the height should be same as that of my page.

height:100%

means nothing by itself...it hs to be 100% of something..and those numbers have to be calculable all the way up the parent-child chain.

So what can the wrapper be 100% of? The answer is the <body> which itself is a child of the <html> element.

Once we set those, it all works as you can't go up the chain any further than the <html> element which is the height of the viewport.

html,
body {
  height: 100%;
  margin: 0;
}
#wrapper {
  height: 100%;
  background-color: blue;
}
<div id="wrapper"></div>

That said, I'd go with min-height:100% on the wrapper to allow for overflow issues if the content exceeds the vireport height.

html {
  height: 100%;
}
body {
  height: 100%;
  margin: 0;
}
#wrapper {
  min-height: 100%;
  background-color: blue;
}

.expander {
  height:1000px;
  }
<div id="wrapper">
<div class="expander"></div>
</div>
Paulie_D
  • 107,962
  • 13
  • 142
  • 161
-1
<!DOCTYPE html>

    <style>
     img.normal {
     height: auto;
     }
     img.big {
     height: 500px;
     }
     p.ex {
     height: 100px;
     width: 100px;
     }
    </style>
    <title></title>
</head>
<body>
    <img class="normal" height="84" src="hari.jpg" width="95"><br>
    <img class="big" height="84" src="hari.jpg" width="95">
    <p class="ex">
        sample
    </p>
</body>