I want to do something like this:

In case 1: content height is smaller than window.
In case 2: content height is larger than window – and scroll shows,
My problem is that content is dynamically changed. So, sometimes .cont height is larger than window height. And then, .foot should be beneath of .cont.
If I set this code
<html>
<head>
<style type="text/css">
.cont{
margin:0 auto;
background-color:#333;
width:800px;
height:500px;
}
.foot {
position:absolute;
left:50%;
margin:0 0 0 -400px;
background-color:#F33;
width:800px;
height:20px;
bottom:0px;
}
</style>
</head>
<body>
<div class="cont"></div>
<div class="foot"></div>
</body>
</html>
I get this:

If you can modify the markup slightly, try Ryan Fait’s Sticky Footer approach:
On his website, he mentions the code solution is free to use without license.