views:

42

answers:

2

Hi

I have a web site. In this i want to scroll a text from bottom to up direction.this column also contain a scroll with up and down arrow. with the same functionality of scroll bar. simple my objective is there is a scrolling text with in a column

+1  A: 

Im old enough to remember doing it with this code:

<marquee direction="up">
    <p> Here will be contentent</p>
    <p>And perhaps an icon <img src="favicon.png"></p>
</marquee>

Dear lord, im old.

pabloacastillo
Wow, what is this 1995? I remember using `marquee` and `blink` tags.
Rocket
The pre-css era. We used <font> and hunted mammoths.When you had to prove yourself debuggin a huge table looking for a <td> without its </td>
pabloacastillo
A: 

I think you may create two divs, one inside another. The outer one should have the following CSS property: overflow:hidden. And it should also have a defined size. The inner one should have position:relative with left and top properties set to 0. Then, you can change the inner one's top property by using Javascript. It's only an idea, I haven't tested it, but it may help you.

<script type="text/javascript">
var currentY=0;
var height;
function scrollUp () {
    height=document.getElementById("innerdiv").offsetHeight;
    if (currentY<height) currentY++;
    document.getElementById("innerdiv").style.height=currentY+"px";
}
function scrollDown () {
    height=document.getElementById("innerdiv").offsetHeight;
    if (currentY>0-height) currentY--;
    document.getElementById("innerdiv").style.height=currentY+"px";
}
</script>
<div style="overflow: hidden; width: 200px; height: 150px; padding: 0px">
    <div style="position: relative; left: 0px; top: 0px; margin: 0px" id="innerdiv">
        <!-- some long text here -->
    </div>
</div>

For this code, you can have two buttons, with scrollUp and scrollDown functions assigned to them. Implementing a dragable scrollbar would be hard. I hope I helped you at least a bit. Maybe there exists a smarter solution than mine, that I don't even know about? Try to look for it. I don't give any warranty for this code to work, maybe there are typos and other mistakes in it. It is just a shape of my idea.

EDIT: don't use this code. It is long and complicated. Check my comment below...

rhino
I was right - there really exists a better way to do it. I have found it today. Comparing to it, my code above is sooo complicated... the great solution which I am talking about is using the scrollTop property. Check out this page (scroll down to the last example on it): http://www.drybro.com/js-scroll.shtml
rhino