style.css
<style> body { background:rgb(255,153,51); } div#wrapper { width:90%; height:100px; margin:0 auto; background:rgb(255,204,0); } ul#menu { width:100%; list-style:none; background:white; } ul#menu li { float:left; padding:0 2em; } ul#menu li#link_1, ul#menu li#link_2, ul#menu li#link_3 { cursor:pointer; } ul#menu li#link_1 { background:rgb(255,80,80); } ul#menu li#link_2 { background:rgb(125,255,0); } ul#menu li#link_3 { background:rgb(0,125,190); } ul#menu li#link_1:hover, div#panels div#item_1 { background:rgb(255,100,100); } ul#menu li#link_2:hover, div#panels div#item_2 { background:rgb(165,255,40); } ul#menu li#link_3:hover, div#panels div#item_3 { background:rgb(20,145,190); } div#panels { width:100%; } div#panels div { width:100%; display:none; } </style>
index.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl"> <head> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style/style.css" media="all" /> </head> <body> <div id="wrapper"> <ul id="menu"> </ul> <div id="panels"> </div> </div> </body> </html>
menu.js
( To jest javascript ale użyłem tagu PHP bo inne rozwalają wcięcia kodzie. )
<?php function Fold_Collection($default) { this.default_ = $default; var ths = this; this.append = function($fold) { this.folds[this.folds.length] = $fold; } this.load = function() { var $links = $("ul#menu"); var $panels = $("div#panels"); { $fold = new Fold($($links.get($i)), $($panels.get($i)), ths); $fold.setEvtClick(); ths.append($fold); }); } this.deactivate = function() { for(var $i = 0; $i < this.folds.length; $i++) { this.folds[$i].deactivate(); } } this.init = function() { $("document").ready( function() { ths.load(); }); } } function Fold($anch, $fold, $parent) { this.anch_ = $anch; this.fold_ = $fold; this.parent_ = $parent; this.setEvtClick = function() { this.anch_.click( function() { this.parent_.deactivate(); this.activate(); }); } this.activate = function() { } this.deactivate = function() { } } $folds = new Fold_Collection(0); $folds.init(); ?>
Poradziłem sobie reorganizując style i dodając jedną klasę z takimi samymi ustawieniami jak :hover. Pobrać stylów dla :hover niestety nie zdołałem.
<style> ul#menu { width:100%; list-style:none; background:white; } ul#menu li { float:left; padding:0 2em; } li#link_1, li#link_2, li#link_3 { cursor:pointer; } li#link_1, div#item_1 { background:rgb(255,80,80); } li#link_2, div#item_2 { background:rgb(25,255,80); } li#link_3, div#item_3 { background:rgb(20,145,190); } li.link_active, li#link_1:hover, li#link_2:hover, li#link_3:hover { /*filter:alpha(opacity=100);*/ -moz-opacity:1; -khtml-opacity:1; /*opacity:1;*/ } li.link_inactive { /*filter:alpha(opacity=70);*/ -moz-opacity:0.7; -khtml-opacity:0.7; /*opacity:0.7;*/ } </style>