欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS+DIV+CSS排版布局實現(xiàn)美觀的選項卡效果

 更新時間:2015年10月10日 10:42:44   作者:企鵝  
這篇文章主要介紹了JS+DIV+CSS排版布局實現(xiàn)美觀的選項卡效果,通過簡單的div+css布局結(jié)合JavaScript切換頁面樣式實現(xiàn)美觀的選項卡效果,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了JS+DIV+CSS排版布局實現(xiàn)美觀的選項卡效果。分享給大家供大家參考。具體如下:

這是一個基于JavaScript的簡單選項卡代碼,陪新手練習一下Div+CSS排版的技巧,本選項卡可以繼續(xù)美化修飾完善,選項卡在目前在眾多網(wǎng)站上應(yīng)用廣泛,確實是一個很不錯的網(wǎng)頁布局方法。

運行效果截圖如下:

在線演示地址如下:

http://demo.jb51.net/js/2015/js-div-css-pbbj-nav-demo/

具體代碼如下:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DIV CSS排版</title>
<style type="text/css"> 
<!--
body,ul{margin:0; padding:0; list-style:none; font:12px "宋體";}
.test {
 width:500px; 
 margin:20px auto; 
 height:150px;
 background:url("images/9zrgo3.jpg") repeat-x 0 33px; 
 }
.test ul li { 
 float:left; 
 padding:2px 1px 6px 1px; 
 background: url("images/11abdrs.jpg") no-repeat 0 0; 
 }
.test ul li a {
 color:#000;
 width:95px; 
 text-decoration:none; 
 display:block; 
 height:27px;
 line-height:31px;
 text-align:center;
 overflow:hidden;
 }
.test ul li a:hover{
 color:#30F;
 background:#FFF url("images/2vi1df8.jpg") repeat-x 0 0px; 
 }
.test ul li.yes {padding:0;border:none;}
.test ul li.yes a {
 color:#30F;
 width:112px;
 height:35px;
 line-height:40px;
 display:block;
 font-weight:bold;
 margin-bottom:-5px;
 background: url("images/27zgcqc.jpg") no-repeat 0px 0; 
 overflow:hidden;
 } 
.content {
 line-height:50px;
 text-align:center;
 font-size:20px;
 color:red;
 height:112px;
 border:#F8BE05 2px solid; 
 border-top:none; 
 clear:both;
 background:#ECED78;
 }
.no { display:none;}
-->
</style>
<script type="text/javascript" language="javascript"> 
 function test_item(n){
  var menu = document.getElementById("menu");
  var menuli = menu.getElementsByTagName("li");
  for(var i = 0; i< menuli.length;i++){
   menuli[i].className= "";
   menuli[n].className="yes";
   document.getElementById("test"+ i).className = "no";
   document.getElementById("test"+ n).className = "content";
  }
 }
</script>
</head>
<body>
<div class="test">
 <ul id="menu">
  <li class="yes" onclick="javascript:test_item(0);"><a href="#" onfocus="this.blur()">首頁</a></li>
  <li onclick="javascript:test_item(1);"><a href="#" onfocus="this.blur()">連接一</a></li>
  <li onclick="javascript:test_item(2);"><a href="#" onfocus="this.blur()">連接二</a></li>
  <li onclick="javascript:test_item(3);"><a href="#" onfocus="this.blur()">連接三</a></li>
  <li onclick="javascript:test_item(4);"><a href="#" onfocus="this.blur()">連接四</a></li>
 </ul>
 <div class="content" id="test0">
  首頁內(nèi)容
 </div>
 <div id="test1" class="no">
  連接一內(nèi)容
 </div>
 <div id="test2" class="no">
  連接二內(nèi)容
 </div>
 <div id="test3" class="no">
  連接三內(nèi)容
 </div>
 <div id="test4" class="no">
  連接四內(nèi)容
 </div>
</div>
</body>
</html>

希望本文所述對大家的JavaScript程序設(shè)計有所幫助。

相關(guān)文章

  • 探討JavaScript語句的執(zhí)行過程

    探討JavaScript語句的執(zhí)行過程

    本文給大家介紹JavaScript語句的執(zhí)行過程的相關(guān)知識,對js語句執(zhí)行過程的相關(guān)知識感興趣的朋友一起學習吧
    2016-01-01
  • canvas繪制表盤時鐘

    canvas繪制表盤時鐘

    本文主要分享了canvas繪制表盤時鐘的示例代碼。具有很好的參考價值,下面跟著小編一起來看下吧
    2017-01-01
  • Bootstrap CSS布局之表單

    Bootstrap CSS布局之表單

    這篇文章主要介為大家詳細紹了Bootstrap CSS布局之表單的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • JS的空值合并運算符(??)的使用

    JS的空值合并運算符(??)的使用

    空值合并運算符是一個邏輯運算符,當左側(cè)的操作數(shù)為null或undefined時,會返回右側(cè)操作數(shù),否則返回左側(cè)操作數(shù),本文就來詳細的介紹一下如何使用
    2023-12-12
  • 最新評論