Jump to content
php.lv forumi

Recommended Posts

Posted (edited)

Nu es te šur tur parakos un atradu tadu php scriptiņu lai darbotos tas , ka uzspiežot uz kāda menu linka , menu tabs izceljas.

līdz šim es dažādi izmēģinājos liidz nelabumam ar pliku css , bet ne čiku ne grabu nesanāca.

Tad nu problema tāda , ka tiek ielādēta tikai menu taba kreisā puse , neveidojot kopaa smuku tabu ar abu pušu bildeem.

 

php&html kods:

 

function menu ($selected = "sakums") {
global $BASEURL;
$script_name = $_SERVER["SCRIPT_FILENAME"];
if (preg_match("/index/i", $script_name)) {
	$selected = "sakums";
}elseif (preg_match("/forums/i", $script_name)) {
	$selected = "forums";
}elseif (preg_match("/raksti/i", $script_name)) {
	$selected = "raksti";
}elseif (preg_match("/fufelis/i", $script_name)) {
	$selected = "fufelis";
}elseif (preg_match("/blabla/i", $script_name)) {
	$selected = "blabla";
}else
	$selected = "";
print ("<ul class=\"navigacija\">");
print ("<li" . ($selected == "sakums" ? " class=current" : "") . "><a href=\"index.php\" >Sākums</a></li>");
print ("<li" . ($selected == "forums" ? " class=current" : "") . "><a href=\"forums.php\">Forums</a></li>");
print ("<li" . ($selected == "raksti" ? " class=current" : "") . "><a href=\"raksti.php\">Raksti</a></li>");
print ("<li" . ($selected == "fufelis" ? " class=current" : "") . "><a href=\"fufelis.php\">Fufelis</a></li>");
print ("<li" . ($selected == "blabla" ? " class=current" : "") . "><a href=\"blabla.php\">BlaBla</a></li>");
}

css kods:

 

}
.navigacija{
position: relative;
padding: 0 0 0 34px;
margin: 0 auto 0 auto;
background: url(menu/menuo_bg.gif) repeat-x; /*tab background image path*/
height: 46px;
list-style: none;

}

.navigacija li{
float:left;
}

.navigacija li a{
float: left;
display: block;
color:#000;
text-decoration: none;
font-family: sans-serif;
font-size: 13px;
font-weight: bold;
padding:0 0 0 16px; /*Padding to accomodate left tab image. Do not change*/
height: 46px;
line-height: 46px;
text-align: center;
cursor: pointer;	
}

.navigacija li a b{
float: left;
display: block;
padding: 0 24px 0 8px; /*Padding of menu items*/
}

.navigacija li.current a , .navigacija li a:hover{
color: #fff;
background: url(menu/menuo_hover_left.gif) no-repeat; /*left tab image path*/
background-position: left;
}

.navigacija li.current a b, .navigacija li a:hover b{
color: #fff;
background: url(menu/menuo_hover_right.gif) no-repeat right; /*right tab image path*/
}

Edited by tirlinjsh
Posted

Cik es nopratu tu gribu lai kad uspiezot uz kada menu lienkiem tiesi tas links iezimejas kada zita krasa, un paliek tada pasa krasa visu laiku kamer tu vandies tiesi pa to lapu. Cerams es pareizi sapratu tavu domu.

Posted (edited)

A tev neder

a:active{
color:red;
}

Vienigi a:active skiet uz daziem browseriem nestrada!

Edited by phpjanis
Posted

Nu ta man sodien miegs nenaca un labs garigais bija taka es teu salaboju tavu scriptu un man vins stradaja normali nez ka teu busss.

 

function menu() {
$script_name = $_SERVER["SCRIPT_FILENAME"];
if (preg_match("/frame/i", $script_name)) {
	$selected = "sakums";
}elseif (preg_match("/forums/i", $script_name)) {
	$selected = "forums";
}elseif (preg_match("/raksti/i", $script_name)) {
	$selected = "raksti";
}elseif (preg_match("/fufelis/i", $script_name)) {
	$selected = "fufelis";
}elseif (preg_match("/blabla/i", $script_name)) {
	$selected = "blabla";
}else{
	$selected = "";
}

 return $selected;
}
print ("<ul class=\"navigacija\">");
print ("<li" . (menu() == "sakums" ? " class=current" : "") . "><a href=\"frame.php\" >Sākums</a></li>");
print ("<li" . (menu() == "forums" ? " class=current" : "") . "><a href=\"forums.php\">Forums</a></li>");
print ("<li" . (menu() == "raksti" ? " class=current" : "") . "><a href=\"raksti.php\">Raksti</a></li>");
print ("<li" . (menu() == "fufelis" ? " class=current" : "") . "><a href=\"fufelis.php\">Fufelis</a></li>");
print ("<li" . (menu() == "blabla" ? " class=current" : "") . "><a href=\"blabla.php\">BlaBla</a></li>");
print ("</ul>");

Posted

Darkangel, tu to kodu pārbaudiji? Uzmetot aci, jau rādās, ka viņš nestrādās.

Ja mācēsi lietot šo, tad ideāls ->

<?
 function active($menu,$x=1){
  global $_SERVER;
  $xx=explode("/",$_SERVER['REQUEST_URI']);
  return ($xx[$x]==$menu) ? true : false;
 }
?>

×
×
  • Create New...