PDA

View Full Version : Pro nèo cho minh hỏi tí



ottogen
23-12-2008, 14:07
Mình thấy đại đa số các trang Wed bây giờ có đoạn code để hình chạy theo thanh cuộn. Pro nào bít chỉ dùm mình đoạn code đó thui..Thanks

final_wizards
24-12-2008, 09:48
Mình thấy đại đa số các trang Wed bây giờ có đoạn code để hình chạy theo thanh cuộn. Pro nào bít chỉ dùm mình đoạn code đó thui..Thanks

Lần trước mình cũng đã lập một hiệu ứng như vậy. Dưới đây là toàn bộ đoạn mã. Nếu bạn không thấy ưng ý thì lấy đoạn mã ở các trang web có hiệu ứng đó mà dùng cũng được.


<div id="khoa" style="border:1px solid #000080; position:absolute;top:20px;left:10px; height:165px; width:178px; background-color:#D8D8D8; padding-left:0px; padding-right:0px; padding-top:1px; padding-bottom:1px"
onmouseover="hamsang('#C0C0C0','#000080')" onmouseout="hamsang('#D8D8D8','#0000FF')" onmousedown="hamsang('#C0C0C0','#ffffff')" onmouseup="hamsang('#C0C0C0','#000080')">
<div align="center">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="165">
<tr>
<td align="center" colspan="2" bgcolor="#336699"><b>
<font face="Arial" size="2" color="#FFFFFF">
Menu theo chu***7897;t ©</font></b></td>
</tr>
<tr>
<td width="15%" align="center" bgcolor="#C0C0C0"><b><font face="Arial" size="2">1</font></b></td>
<td width="85%"><b><font face="Arial" size="2" color="#0000FF"><div id="muc1" style="height:10px; width:160px">
&nbsp;Trang ch***7911;</div></font></b></td>
</tr>
<tr>
<td width="15%" align="center" bgcolor="#C0C0C0"><b><font face="Arial" size="2">2</font></b></td>
<td width="85%"><b><font face="Arial" size="2" color="#0000FF"><div id="muc1" style="height:10px; width:160px">
&nbsp;Thông tin</div></font></b></td>
</tr>
<tr>
<td width="15%" align="center" bgcolor="#C0C0C0"><b><font face="Arial" size="2">3</font></b></td>
<td width="85%"><b><font face="Arial" size="2" color="#0000FF"><div id="muc1" style="height:10px; width:160px">
&nbsp;Di***7877;n ***273;àn trao ***273;***7893;i</div></font></b></td>
</tr>
<tr>
<td width="15%" align="center" bgcolor="#C0C0C0"><b><font face="Arial" size="2">4</font></b></td>
<td width="85%"><b><font face="Arial" size="2" color="#0000FF"><div id="muc1" style="height:10px; width:160px">
&nbsp;Liên k***7871;t</div></font></b></td>
</tr>
<tr>
<td width="15%" align="center" bgcolor="#C0C0C0"><b><font face="Arial" size="2">5</font></b></td>
<td width="85%"><b><font face="Arial" size="2" color="#0000FF"><div id="muc1" style="height:10px; width:160px">
&nbsp;KVC2 Web</div></font></b></td>
</tr>
<tr>
<td width="15%" align="center" bgcolor="#C0C0C0"><b><font face="Arial" size="2">6</font></b></td>
<td width="85%"><b><font face="Arial" size="2" color="#0000FF"><div id="muc1" style="height:10px; width:160px">
&nbsp;Tác gi***7843;</div></font></b></td>
</tr>
<tr>
<td width="15%" align="center" bgcolor="#C0C0C0"><b><font face="Arial" size="2">7</font></b></td>
<td width="85%"><b><font face="Arial" size="2" color="#0000FF"><div id="muc1" style="height:10px; width:160px">
&nbsp;Giúp ***273;***7905;</div></font></b></td>
</tr>
</table>
</div>
</div>

<script language="javascript">
var thoigian
window.onscroll=hamtheochuot
function hamtheochuot()
{
var bientinh=window.document.body.scrollTop;
clearTimeout(thoigian)
ham(bientinh)
}

function ham(thamso1)
{
var biendiv=window.document.all.khoa.style
if(thamso1<parseInt(biendiv.top)-20){biendiv.top=parseInt(biendiv.top)-1}
if(thamso1>parseInt(biendiv.top)-20){biendiv.top=parseInt(biendiv.top)+1}
var chuyenchuoi="ham("+thamso1+");"
thoigian=setTimeout(chuyenchuoi,10)
}

function hamsang(mauthanh,mauchu)
{
if(event.srcElement.id=="muc1")
{event.srcElement.style.backgroundColor=mauthanh
event.srcElement.style.color=mauchu}
}
</script>

ottogen
27-12-2008, 12:46
thanks pro nhìu........cám ơn nha