Skip to content Skip to sidebar Skip to footer

Prevents Relative Css Heights

(Everything is tested in the latest firefox.) This html-code creates an almost screen-filling red box:

Solution 2:

You can do it this way: http://cdpn.io/aHlCd

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<style media="all">

html, body {height: 100%; margin: 0; padding: 0;}
div {min-height: 100%; background: red;}

</style>

</head>
<body>

<div></div>

</body>
</html>

You can also just set height on the div rather than min-height.


Solution 3:

The above is the answer to why, if you were looking for a fix, setting the position to absolute and applying top,right,left and bottom should do the trick:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <div style="position: absolute;height:100%;background-color:red;bottom: 0;top: 0;right: 0;left: 0"></div>
</body>
</html>

Post a Comment for " Prevents Relative Css Heights"