Dalam sebuah aplikasi php kerap kali kita temukan tabs
dimana tab-tab tersebut mempunyai fungsi yang berbeda
Kita akan kupas tuntas bagaimana cara membuat tab seperti
pada gambar dibawah ini
1. yang perlu kita lakukan adalah mendownload jquery kita
bisa download
disini
2.siapkan file index.htm ataupun file project kita
3.siapkan file untuk css
step 1 file index.html
02 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
03 | <title>Membuat Tabs Dengan CSS dan jQuery</title> |
04 | <link rel="stylesheet" type="text/css" href="css/reset-font.css" media="screen" /> |
05 | <link rel="stylesheet" type="text/css" href="css/screen.css" media="screen" /> |
06 | <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> |
07 | <script type="text/javascript"> |
08 | $(document).ready(function() { |
09 | $('#tab1').fadeIn('slow'); //tab pertama ditampilkan |
10 | $('ul#nav li a').click(function() { // jika link tab di klik |
11 | $('ul#nav li a').removeClass('active'); //menghilangkan class active (yang tampil) |
12 | $(this).addClass("active"); // menambahkan class active pada link yang diklik |
13 | $('.tab_konten').hide(); // menutup semua konten tab |
14 | var aktif = $(this).attr('href'); // mencari mana tab yang harus ditampilkan |
15 | $(aktif).fadeIn('slow'); // tab yang dipilih, ditampilkan |
26 | <h1>Membuat Tabs Dengan CSS dan jQuery</h1> |
28 | <li><a href="#tab1" class="active">Home</a></li> |
29 | <li><a href="#tab2">About</a></li> |
30 | <li><a href="#tab3">Contact</a></li> |
32 | <div class="clear"></div> |
34 | <div style="display: none;" id="tab1" class="tab_konten"> |
36 | <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque ut quam. Pellentesque vestibulum, velit eget venenatis auctor, quam turpis consequat quam, et ultricies leo neque et tortor. Quisque ut nulla non neque facilisis mattis. Sed quis nibh blandit lacus laoreet feugiat. <a href="#" title="Online Store">Vestibulum</a> ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris tincidunt erat nec risus accumsan tincidunt. Nunc augue massa, accumsan a, mollis vitae, porttitor eu, leo. Vestibulum purus. </p> |
39 | <div style="display: none;" id="tab2" class="tab_konten"> |
41 | <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque ut quam. Pellentesque vestibulum, velit eget venenatis auctor, quam turpis consequat quam, et ultricies leo neque et tortor. Quisque ut nulla non neque facilisis mattis. Sed quis nibh blandit lacus laoreet feugiat. <a href="#" title="Online Store">Vestibulum</a> ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris tincidunt erat nec risus accumsan tincidunt. Nunc augue massa, accumsan a, mollis vitae, porttitor eu, leo. Vestibulum purus. </p> |
44 | <div style="display: none;" id="tab3" class="tab_konten"> |
46 | <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque ut quam. Pellentesque vestibulum, velit eget venenatis auctor, quam turpis consequat quam, et ultricies leo neque et tortor. Quisque ut nulla non neque facilisis mattis. Sed quis nibh blandit lacus laoreet feugiat. <a href="#" title="Online Store">Vestibulum</a> ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris tincidunt erat nec risus accumsan tincidunt. Nunc augue massa, accumsan a, mollis vitae, porttitor eu, leo. Vestibulum purus. </p> |
49 | <div id="footer">read other cool stuff at my <a href="http://d3dykurniadi.wordpress.com" title="dedy kurniadi">blog</a>, back to <a href="#" title="back to article">article</a> or <a href="#" title="download source">download</a> this source :)</div> |
setelah code diatas dibuat kita siapkan du file css yaitu screen.css dan reset-font.css
screen.css
51 | padding : 20px 5px 10px 0 ; |
64 | font-weight : bold ; display : block ; |
69 | ul#nav li a.active, ul#nav li a.active:hover{ |
kemudian siapkan juga file yang ketiga yaitu reset-font.css
04 | html, body, div, span, applet, object, iframe, |
05 | h 1 , h 2 , h 3 , h 4 , h 5 , h 6 , p, blockquote, pre , |
06 | a, abbr, acronym, address, big, cite, code , |
07 | del, dfn, em, font, img, ins, kbd, q, s, samp, |
08 | small , strike, strong, sub , sup, tt, var, |
10 | dl, dt, dd, ol, ul, li, |
11 | fieldset, form, label, legend, |
12 | table, caption , tbody, tfoot, thead, tr, th, td { margin : 0 ; padding : 0 ; border : 0 ; outline : 0 ; font-size : 100% ; vertical-align : baseline ; background : transparent ; } |
13 | body { line-height : 1 ; } |
14 | ol, ul { list-style : none ; } |
15 | blockquote, q { quotes : none ; } |
16 | blockquote:before, blockquote:after, |
17 | q:before, q:after { content : '' ; content : none ; } |
19 | ins { text-decoration : none ; } |
20 | del { text-decoration : line-through ; } |
21 | table { border-collapse : collapse ; border-spacing : 0 ; } |
25 | body{ font : 13px / 1.231 Georgia, "Times New Roman" , Times, serif ;* font-size : small ;* font : x-small ;}select,input,button,textarea,button{ font : 99% Georgia, "Times New Roman" , Times, serif ;}table{ font-size :inherit; font : 100% ;} pre , code ,kbd,samp,tt{ font-family : monospace ;* font-size : 108% ; line-height : 100% ;}</ pre > |
jangan lupa masukan file jquery pada folder js setelah semua langkah sudah dijalankan coba sekarang kita akses localhost/folderkita
0 comments:
Post a Comment