i created a div made it scrollable with <p>text</p>
as seen below:
the code has 2 scrollable buttons that change color once they scrolled all the way to the end.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style rel="stylesheet" type="text/css">
#scroller
{
border: 1px solid black;
height: 80px;
width: 400px;
overflow-y: hidden;
overflow-x: hidden;
}
a
{
display:block;
padding:10px;
background-color:red;
width:25px;
position:relative;
top:20px;
}
div
{
float:left;
}
#type
{
position:absolute;
top: 100px;
left: 250px
}
#left
{
background-color:blue;
}
</style>
<script type="text/javascript">
var PixelPerInterval = 1;
var stop = false;
var t;
var scroll_width;
function scroll_left()
{
document.getElementById('right').style.backgroundColor='red';
document.getElementById('scroller').scrollLeft-=PixelPerInterval;
if(!stop)
t = setTimeout("scroll_left()",10);
else
stop = false;
scrX = document.getElementById('scroller').scrollLeft;
divwidth=document.getElementById('scroller').clientWidth;
pwidth=document.getElementById('cont').clientWidth;
type.innerHTML = scrX;
if ((scrX) <= 0)
//type.innerHTML = scrX + ' left';
document.getElementById('left').style.backgroundColor='blue';
}
function scroll_right()
{
document.getElementById('left').style.backgroundColor='red';
document.getElementById('scroller').scrollLeft+=PixelPerInterval;
if(!stop)
t = setTimeout("scroll_right()",10);
else
stop = false;
scrX = document.getElementById('scroller').scrollLeft;
divwidth=document.getElementById('scroller').clientWidth;
pwidth=document.getElementById('cont').clientWidth;
type.innerHTML = scrX;
if ((divwidth+scrX) >= pwidth)
//type.innerHTML = scrX + ' right';
document.getElementById('right').style.backgroundColor='blue';
}
function stop_scroll() {
stop = true;
}
</script>
</head>
<body>
<div><a id="left" onmouseover="scroll_left();" onmouseout="stop_scroll();" href="#">Left</a></div>
<div id="scroller">
<p id="cont" style="width:700px;">
alot of textalot of textalot of textalot of textalot of textalot of textalot of textalot of textalot of text<br/>
alot of textalot of textalot of textalot of textalot of textalot of textalot of textalot of textalot of text<br/>
alot of textalot of textalot of textalot of textalot of textalot of textalot of textalot of textalot of text<br/>
alot of textalot of textalot of textalot of textalot of textalot of textalot of textalot of textalot of text<br/>
alot of textalot of textalot of textalot of textalot of textalot of textalot of textalot of textalot of text<br/>
</p>
</div>
<div><a id="right" onmouseover="scroll_right();" onmouseout="stop_scroll();" href="#">Right</a></div>
<p id="type">asd</p>
</body>
when adding pictures they won't overflow to the right and only down.
thanks alot for the help.