-1

I set "height" CSS property in percent (%) for div element but html render noting. But if I set "height" CSS property in length values, like px, cm, etc it works. Can any one help me?

   <html>  
        <head>  
        <meta name="viewport" content="width=device-width, initial-scale=1.0">  
        </head>  
        <body>  
        <div style="width: 40%; height: 40%; background-color: #565;  ">  
        </div>  
        </body>  
    </html>
Nitin Pawar
  • 168
  • 1
  • 10

2 Answers2

1

first of all you need to set html, body width and height to 100%, so set them in your stylesheet like that

html,body{
    height:100%;
    width:100%;
}

after that your problem will be solved

Dato DT
  • 129
  • 1
  • 1
  • 9
1

Try using this...

width: 40vw;
height: 40vh;
ElusiveCoder
  • 1,593
  • 1
  • 8
  • 23