DIV CSS 佈局教程網

JS 實作簡潔縱向滑動選單(滑動門)效果
編輯:關於JavaScript     

本文為大家示範以 JS 實作的簡潔縱向滑動選單(滑動門)效果,希望對學習中的朋友有所幫助。

這是一款縱向布局的 CSS+JavaScript 滑動門程式碼,手法相當簡潔。若對顏色不滿意,你可以自行修改 CSS。這個滑動門將每一「門」的內容存進 JS 陣列中,這樣可以減少程式碼量,但也帶來擴充性的問題,仍有待完善,僅供參考。

運行效果截圖如下:

線上演示網址如下:

https://demo.jb51.net/js/2015/js-simple-zxhd-menu-demo/

具體程式碼如下:

<html>
<head>
<title>縱向滑動門</title>
<style>
td,a,body{font-size:9pt;}
.DivAround_focus{cursor:pointer;background-color:#A1ACDB;border-right:solid 1px #A1ACDB;border-bottom:solid 1px #333333;border-left:solid 1px #C8CEEA;border-top:solid 1px #C8CEEA;color:#000000}
.DivAround_blur{cursor:pointer;background:#4D5C9F;border-right:solid 1px #eeeeee;border-bottom:solid 1px #333333;border-left:solid 1px #798ACC;border-top:solid 1px #A1ACDB;color:#FFFFFF}
.DivAround_content{background-color:#A1ACDB;border-right:solid 1px #888888;border-bottom:solid 1px #555555;border-left:0px;border-top:solid 1px #C8CEEA;}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<table cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#6271B1">
<tr><td valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="84" id="leftButtonTAble">
  <tr><td height="20" align="center" class="DivAround_focus" onMouseOver="ChangeFocus(this)">七星彩</td></tr>
  <tr><td height="20" align="center" class="DivAround_blur" onMouseOver="ChangeFocus(this)">排列五</td></tr>
  <tr><td height="20" align="center" class="DivAround_blur" onMouseOver="ChangeFocus(this)">籃球彩</td></tr>
  <tr><td height="22" align="center" class="DivAround_blur" onMouseOver="ChangeFocus(this)">足球彩</td></tr>
</table>
</td>
<td>
<table width="303" border="0" cellpadding="0" cellspacing="0" class="DivAround_content">
  <tr><td valign="top" id="DivAroundContent" height=80></td></tr>
</table>
</td></tr>
</table>
<script language="javascript">
ChangeFocus(document.getElementById("leftButtonTAble").rows[0].cells[0]);
</script>
</body></html>
<script language="javascript">
var AroundInfoArray=new Array();
AroundInfoArray[0]="七星彩";
AroundInfoArray[1]="排列五";
AroundInfoArray[2]="籃球彩";
AroundInfoArray[3]="足球彩";
function ChangeFocus(obj) {
  for(i=0;i<document.getElementById("leftButtonTAble").rows.length;i++) {
    if(document.getElementById("leftButtonTAble").rows[i].cells[0]==obj) {
      document.getElementById("leftButtonTAble").rows[i].cells[0].className="DivAround_focus";
      document.getElementById("DivAroundContent").innerHTML=AroundInfoArray[i];
    }else{
      document.getElementById("leftButtonTAble").rows[i].cells[0].className="DivAround_blur";
    }
  }
}
</script>

希望本文所述能對大家的 JavaScript 程式設計有所幫助。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved