2

I want to add background to div. If content height will be small, background will be cutted. If I add min-height, when window height is small, there are apeears scrollbar.. Help please)

acidernt
  • 2,173
  • 2
  • 19
  • 33
  • 2
    http://stackoverflow.com/questions/1575141/make-div-100-height-of-browser-window OR http://jsfiddle.net/JamesD/hr8sL/ –  Sep 28 '13 at 09:34

3 Answers3

3

Jacob is all right, just add a width property also,

div {
    height:100%;
    width:100%;
    background:#f00;
    color:#fff;
    position: fixed;
}
Sunny Sharma
  • 4,688
  • 5
  • 35
  • 73
1

Not sure if I understood your question but try this:

div {
    width: 100%;
    height:100%;
    background:#f00;
    color:#fff;
    position: fixed;
}
Jacob
  • 1,933
  • 2
  • 20
  • 30
0

For this purpose you should use some javascript.

function wh()
{
var height = window.innerHeight;
var width = window.innerWidth;

document.getElementById('--your div ID--').style.height = height;
document.getElementById('--your div ID--').style.width = width;
}

Now call that function wh() on body load. i.e.,

<body onload="wh()"></body>
navin2013
  • 11
  • 2