Click to See Complete Forum and Search --> : Movable Elements


said_fox
06-04-2004, 10:54 PM
Hi,
How can I make an HTML element Movable? For example, suppose

<div id="skin1" style="width:60px;height:30px;postion:absolute;top:30px;left:20px">
SomeThing
</div>

I want to make this "div" move when I scroll down or up the page, i.e to change the "top" vlaue.
If it is complicated to be discused in a reply, I would be apprecited to let me know a link for a tutorial or an article discuss this case.
:rolleyes:

Mr J
06-05-2004, 08:59 AM
Please try the following

<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
<script>
function scrollme(){
document.getElementById("skin1").style.top=document.body.scrollTop+150
}
onscroll=scrollme
</script>
</HEAD>
<BODY>
<div id="skin1" style="width:60px;height:30px;position:absolute;top:30px;left:20px;background-color:#c0c0c0">SomeThing</div>
dummy text<BR><BR><BR><BR><BR>
dummy text<BR><BR><BR><BR><BR>
dummy text<BR><BR><BR><BR><BR>
dummy text<BR><BR><BR><BR><BR>
dummy text<BR><BR><BR><BR><BR>
dummy text<BR><BR><BR><BR><BR>
</BODY>
</HTML>

said_fox
06-05-2004, 06:16 PM
Ok, Yes your example is working so nice. Thank you for help
:D :D :D :D :D