I have HTML document based on twitter Bootstrap, which is like:
<DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<nav></nav>
<div class="container" id="main"></div>
<footer class="footer"></footer>
</body>
</html>
I know that <nav>
is 50px high and <footer>
is 20px high.
I want my div to be 20px from the navbar and 20px from the footer. Also, I want scrollbars to appear only in div, not on the whole page, so I have a CSS stylesheet like this:
body {
padding-top: 70px;
padding-bottom: 40px;
overflow: hidden;
}
#main.container {;
overflow: auto;
}
.footer {
position: fixed;
bottom: 0px;
width: 100%;
height: 20px;
text-align: center;
}
The problem is, that to use overflow:auto I have to define div height and I need this div to fill the screen.
Can someone tell me how can i do that?
Thanks for help,
Cyanide
4
Answers
I've solved this problem with jQuery:
But thanks everybody for answers.
Position the container absolute and give it ‘top’ and ‘bottom’ so that you do not need to use height!
Something like this – DEMO
One option is to use absolute positioning on the container.
Something like:
As I can understand you do not want to define the height in order to fit any screen size.
You could set the heigh, calculate the size of the screen with javascript
then set the new heigh (screen – nav – footer), like
new_height
must be a string.