Simple example with div below another div, the first one displays a video with a 100% width, the other one's got some overflowing text inside.. all I want is to scroll the second div instead of a whole page:
<div id="bot" style="overflow:auto;">
http://jsfiddle.net/H7uhM/1/
//edit I removed z-index because it's a leftover from the master code. The height of video may vary, and that's why setting the #bot div to a constant height is not the solution. The video depends on a ration my have between 35%-50% of the page's height.
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.
Just use overflow: auto . Since your content by default just breaks to the next line when it cannot fit on the current line, a horizontal scrollbar won't be created (unless it's on an element that has word-wrapping disabled). For the vertical bar,it will allow the content to expand up to the height you have specified.
use css position top keep it at the bottom {position : relative; bottom:0;} . Remove the css property once the user has scroll.
you need to change your style to be overflow-y: scroll;
and you need a height otherwise the element will continue growing to accommodate the contents.
Example:
<div id="bot" style="overflow-y:scroll; height: 250px;">
Also, the z-index was irrelevant
If you want to use Javascript, you can achieve your desired effect like this:
<script>
window.onload = function () {
var bot = document.getElementById('bot');
bot.style.height = (window.innerHeight - document.getElementById('top').offsetHeight) + "px";
}
</script>
JSFiddle
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