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)
Asked
Active
Viewed 2,458 times
3 Answers
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