The HTML should be sth like the following (sorry for the format and formatting but I do not know how to post HTML sample)
<div id="dialog-window">
<div id="scrollable-content">
what ever content here...div's, ul's and li's
</div>
<div id="footer">
</div>
</div>
The result i'm looking for is to always have a vertical scrollbar only for the content and the footer should be always visible at the bottom of the dialog-window. The dialog-window is a fixed size dialog.
I have tried with some ideas from other posts here but do not fit all requirements. Any ideas to do this using CSS (js and jquery also welcome)
You need to put position: fixed; on the div element. That will anchor it to the viewport.
For vertical scrollable bar use the x and y axis. Set the overflow-x:hidden; and overflow-y:auto; that will automatically hide the horizontal scroll bar and present only vertical scrollbar. Here the scroll div will be vertically scrollable.
Set the position of div at the bottom of its container can be done using bottom, and position property. Set position value to absolute and bottom value to zero to placed a div at the bottom of container.
We can use a combination of overflow-x and overflow-y to place the scrollbar vertically, horizontally, or both. For the vertical scrollbar, overflow-x:hidden and overflow-y:auto will be set in the CSS file, and vice versa for the horizontal scrollbar.
How about something like the below?
Just create a container which holds two divs one for the scrollable content and one for the footer. Fix all the heights and make the content div scrollable.
CSS (I won't charge for my expert color choices):
#dialog-window {
height: 200px;
border: 1px black solid;
}
#scrollable-content {
height: 180px;
overflow: auto;
background-color: blue;
}
#footer {
height: 20px;
background-color: green;
}
Example of HTML
<div id="dialog-window">
<div id="scrollable-content">
<ul>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
<li>Sample</li>
</ul>
</div>
<div id="footer">
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With