Advertisement
ssaidz

tab css js

Sep 19th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.83 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Tab Menu Dengan CSS dan JavaScript </title>
  6. <style type="text/css">
  7.     #tabs {
  8.         display: block;
  9.         float: left;
  10.         width: 200px;
  11.     }
  12.     .panel {
  13.         border: solid 1px #D8D8D8;
  14.         font-family:tahoma;
  15.         font-size:14px;
  16.         border-top: none;
  17.         background-color: #FFFFFF;
  18.         padding: 0px;
  19.         width: 180px;
  20.         overflow: auto;
  21.         clear: left;
  22.     }
  23.     .tab_bdr {
  24.         padding: 0px;
  25.         width: 180px;
  26.         border: 0px;
  27.         border: 1px solid #CCCCCC;
  28.         height: 4px;
  29.         margin:0px;
  30.         background: #CCCCCC;
  31.         clear: left;
  32.         font-size: 0px;
  33.     }
  34.     .tab {
  35.         font-family: tahoma;
  36.         font-size: 12px;
  37.         background:#00F;
  38.         color: #FFFFFF;
  39.         cursor: pointer;
  40.         border: none;
  41.         border-bottom: 1px solid #FFFFFF;
  42.         height: 19px;
  43.         padding-top: 3px;
  44.         margin: 0px;
  45.         width: 60px;
  46.         float: left;
  47.         text-decoration: none;
  48.     }
  49.     .tab_sel {
  50.         font-family: tahoma;
  51.         font-size: 12px;
  52.         background: #CCCCCC;
  53.         color: #FFFFFF;
  54.         cursor: pointer;
  55.         border: none;
  56.         border-bottom: 1px solid #CCCCCC;
  57.         height: 19px;
  58.         padding-top: 3px;
  59.         margin: 0px;
  60.         width:60px;
  61.         float: left;
  62.         text-decoration: none;
  63.     }
  64. </style>
  65. <script language="JavaScript" type="text/javascript">
  66.     var panels = new Array('panel1', 'panel2', 'panel3');
  67.     var tabs = new Array('tab1', 'tab2', 'tab3');
  68.     function displayPanel(nval)
  69.     {
  70.         for(i = 0; i < panels.length; i++)
  71.        {
  72.            document.getElementById(panels[i]).style.display = (nval-1 == i) ? 'block':'none';
  73.            document.getElementById(tabs[i]).className=(nval-1 == i) ? 'tab_sel':'tab';
  74.        }
  75.    }
  76. </script>
  77. </head>
  78.  
  79. <body>
  80.     <div id="tabs">
  81.         <div id="tab1" class="tab_sel" align="center" onClick="javascript: displayPanel('1');">Home</div>
  82.         <div id="tab2" class="tab" style="margin-left:1px;" align="center" onClick="javascript: displayPanel('2');">About Us</div>
  83.                     <div id="tab3" class="tab" style="margin-left:1px;" align="center" onClick="javascript: displayPanel('3');">Products</div>
  84.     </div>
  85.          
  86.     <div class="tab_bdr"></div>
  87.     <div class="panel" id="panel1" style="display: block">Ini halaman home</div>
  88.     <div class="panel" id="panel2" style="display: none">Tentang kami</div>
  89.           <div class="panel" id="panel3" style="display: none">Beberapa products kami</div>
  90. </body>
  91. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement