1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
| <!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="Author" content="Daniel Hagnoul">
<title>Forum jQuery</title>
<style>
body {
background-image:url("http://pckult.developpez.com/tutoriels/javascript/frameworks/jquery/boite-onglets-web2/fichiers/images/background.jpg");
background-repeat:no-repeat;
background-position:top center;
background-color:#657077;
margin:40px;
}
#tabbed_box {
margin: 0px auto 0px auto;
width:300px;
}
.tabbed_box h4 {
font-family:Arial, Helvetica, sans-serif;
font-size:23px;
color:#ffffff;
letter-spacing:-1px;
margin-bottom:10px;
}
.tabbed_box h4 small {
color:#e3e9ec;
font-weight:normal;
font-size:9px;
font-family:Verdana, Arial, Helvetica, sans-serif;
text-transform:uppercase;
position:relative;
top:-4px;
left:6px;
letter-spacing:0px;
}
.tabbed_area {
border:1px solid #494e52;
background-color:#636d76;
padding:8px;
}
ul.tabs {
margin:0px; padding:0px;
}
ul.tabs li {
list-style:none;
display:inline;
}
ul.tabs li a {
background-color:#464c54;
color:#ffebb5;
padding:8px 14px 8px 14px;
text-decoration:none;
font-size:9px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:bold;
text-transform:uppercase;
border:1px solid #464c54;
}
ul.tabs li a:hover {
background-color:#2f343a;
border-color:#2f343a;
}
ul.tabs li a.active {
background-color:#ffffff;
color:#282e32;
border:1px solid #464c54;
border-bottom: 1px solid #ffffff;
}
.content {
background-color:#ffffff;
padding:10px;
border:1px solid #464c54;
}
#content_2, #content_3 { display:none; }
ul.tabs {
margin:0px; padding:0px;
margin-top:5px;
margin-bottom:6px;
}
.content ul {
margin:0px;
padding:0px 20px 0px 20px;
}
.content ul li {
list-style:none;
border-bottom:1px solid #d6dde0;
padding-top:15px;
padding-bottom:15px;
font-size:13px;
}
.content ul li a {
text-decoration:none;
color:#3e4346;
}
.content ul li a small {
color:#8b959c;
font-size:9px;
text-transform:uppercase;
font-family:Verdana, Arial, Helvetica, sans-serif;
position:relative;
left:4px;
top:0px;
}
.content ul li:last-child {
border-bottom:none;
}
ul.tabs li a {
background-image:url("http://pckult.developpez.com/tutoriels/javascript/frameworks/jquery/boite-onglets-web2/fichiers/images/tab_off.jpg");
background-repeat:repeat-x;
background-position:bottom;
}
ul.tabs li a.active {
background-image:url("http://pckult.developpez.com/tutoriels/javascript/frameworks/jquery/boite-onglets-web2/fichiers/images/tab_on.jpg");
background-repeat:repeat-x;
background-position:top;
}
.content {
background-image:url("http://pckult.developpez.com/tutoriels/javascript/frameworks/jquery/boite-onglets-web2/fichiers/images/content_bottom.jpg");
background-repeat:repeat-x;
background-position:bottom;
}
</style>
</head>
<body>
<div id="tabbed_box" class="tabbed_box">
<h4>Navigation <small>Sélectioner un onglet</small></h4>
<div class="tabbed_area">
<ul class="tabs">
<li><a href="#" title="content_1" class="tab active">Astuces</a></li>
<li><a href="#" title="content_2" class="tab">Tutoriaux</a></li>
<li><a href="#" title="content_3" class="tab">Articles</a></li>
</ul>
<div id="content_1" class="content">
<ul>
<li><a href="">HTML / XHTML <small>4 Articles</small></a></li>
<li><a href="">CSS <small>32 Articles</small></a></li>
<li><a href="">Flash <small>2 Articles</small></a></li>
<li><a href="">PHP / MySQL <small>19 Articles</small></a></li>
<li><a href="">Microsoft Windows <small>6 Articles</small></a></li>
<li><a href="">Autres <small>8 Articles</small></a></li>
</ul>
</div>
<div id="content_2" class="content">
<ul>
<li><a href="">HTML / XHTML <small>4 Articles</small></a></li>
<li><a href="">Javascript <small>32 Articles</small></a></li>
<li><a href="">Autres <small>19 Articles</small></a></li>
</ul>
</div>
<div id="content_3" class="content">
<ul>
<li><a href="">Conception Web <small>4 Articles</small></a></li>
<li><a href="">SEO et Référencement <small>32 Articles</small></a></li>
<li><a href="">Programmation <small>2 Articles</small></a></li>
<li><a href="">Autres <small>19 Articles</small></a></li>
</ul>
</div>
</div>
</div>
<script charset="utf-8" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script>
// Une fois le chargment de la page terminé ...
$(function(){
// Lorsqu'un lien a.tab est cliqué
$("a.tab").click(function () {
// Mettre toutes les onglets non actif
$(".active").removeClass("active");
// Mettre l'onglet cliqué actif
$(this).addClass("active");
// Cacher les boîtes de contenu
$(".content").slideUp();
// Pour afficher la boîte de contenu associer, nous
// avons modifier le titre du lien par le nom de
// l'identifiant de la boite de contenu
var contenu_aff = $(this).attr("title");
$("#" + contenu_aff).slideDown();
});
});
</script>
</body>
</html> |
Partager