Jump to content

Need Some Help With Class


ckrudelux

Recommended Posts

Okay I have a link with a class telling how it should look like and I thought that if I did some really great php coding and add a second class to it to change the color of the text at needed moments. But it doesn't overwrite the css code what is set.Hope someone understand what I ment.

Link to comment
Share on other sites

you can just use onclick and javascript?why PHP?maybe a link to the site?
What I'm trying to do is a menu and too know where you are in the menu the text should turn into another color.
Link to comment
Share on other sites

just use css:#link:hover { color:??????; background-color:??????}you can change everything you like this way and you can use that :hover for every tag in the body.

Link to comment
Share on other sites

just use css:#link:hover { color:??????; background-color:??????}you can change everything you like this way and you can use that :hover for every tag in the body.
Okay clearly you don't understand so I'm going to spellit out for you.Here is the css code
.menubutton, .menubutton:visited { color: #000;}.menubutton:hover {color: #f00;}.onpag, onpage:visited {color #f00}
here is the html
<div> <a class="menubutton" if(Some fancy php tells if you are on the place where this point to){echo class="onpage"} href="tosomewhere">Link</a></div>

The point is that onpage class should overwrite the text color. But it doesn't do what.

Link to comment
Share on other sites

Are you looking for the "current" page styling?
I think so. But I don't get why my code doesn't work or is so what I'm not allowed to have two classes in one object?
Link to comment
Share on other sites

Post your full code complete with the php code and then post the browser source from view sourcing the page in your Browser.
My php file:
<div id="left">	<div class="margin10">		<p class="hp">Navigering</p>	</div>	<div id="mframe1">		<div id="mframe2">			<?php			$select = mysql_query("SELECT * FROM menu");			while($row = mysql_fetch_array($select)){			?>			<a title="<?php echo $row['description']; ?>" class="menua" <?php if(!isset($_GET['sm'])){if($_GET['m'] == $row['menu_id']){ echo 'class="onpage"';}}?> href="index.php?<?php echo "m=".$row['menu_id']."&md=".$row['type']; ?>"><?php echo $row['name'];?>				<?php				$menu_id = $row['menu_id'];				$select2 = mysql_query("SELECT * FROM submenu WHERE menu_id='$menu_id'");				$rows = mysql_num_rows($select2);				if($rows > "0"){					if(isset($_GET['m'])){						if($_GET['m'] == $row['menu_id']){						?>							<span class="sizemenua">∨</span></a>						<?php						} else{						?>							<span class="sizemenua">></span></a>						<?php						}					}else {					?>						<span class="sizemenua">></span></a>					<?php					}				}else{				?>				</a>				<?php				}				?>				<br />				<?php				if(isset($_GET['m'])){if($_GET['m'] == $row['menu_id']){				while($row2 = mysql_fetch_array($select2)){				?>				<a title="<?php echo $row2['description']; ?>" class="submenua" <?php if(isset($_GET['sm'])){if($_GET['sm'] == $row2['submenu_id']){ echo 'class="onpage"';}}?> href="index.php?<?php echo "m=".htmlspecialchars($_GET['m'])."&sm=".$row2['submenu_id']."&md=".$row2['type']; ?>"><?php echo $row2['name']; ?></a><br />				<?php				}				}				}			}			?>			<br />		</div>	</div></div>

Here is the css:

	#left {		float: left;		width: 170px;	}		/* Navigate */			#mframe1 {				float: left;				margin-left: 10px;				margin-right: 10px;				width: 150px;				border-top: 4px solid #000;				border-bottom: 4px solid #000;			}			#mframe2 {				float: left;				margin-top: 2px;				margin-bottom: 2px;				width: 149px;				border-right: 1px solid #000;			}						.sizemenua {			font-size: 12px;			}						.menua, .menua:visited {			float: left;			margin-left: 10px;			text-decoration: none;			color: #000;			}						.menua:hover {			color: #f00;			}						.submenua, .submenua:visited {			float: left;			margin-left: 20px;			font-size: 12px;			text-decoration: none;			color: #000;			}						.submenua:hover {			color: #f00;			}						.onpage, .onpage:visited{			color: #f00;			}

Here is the web browser output:

<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" ><head>	 <script>		function clearText(theField)		{		if (theField.defaultValue == theField.value)		theField.value = '';		}		function addText(theField)		{		if (theField.value == '')		theField.value = theField .defaultValue;		}	</script>	<meta name="description" content="Page Module editable home page" />	<meta name="keywords" content="edit, page, easy" />	<meta http-equiv="Content-Type" content="text/xml; charset=iso-8859-1" />		<title>		Page Module	</title>		<link rel="stylesheet" type="text/css" href="style.css" />	</head><body>	<div id="top">		<div id="topmenu">			<div class="topleft"></div>				<div class="topmiddle">												<div id="topmargin">								<form>									<input title="Skriv ditt användarnamn här." class="topinput" type="text" name="username" onblur="addText(this);" onfocus="clearText(this)" value="Användarnamn" />									<input title="Skriv ditt lösenord här." class="topinput" type="password" name="password" onblur="addText(this);" onfocus="clearText(this)" value="lösenord" />									<a title="Klicka för att logga in." class="topa" href="" onClick="document.submit()">Logga in</a>								</form>							</div>										</div>			<div class="topright"></div>		</div>		<div id="topbox">			<div id="logo"></div>			<div id="search">				<div class="topleft"></div>				<div class="topmiddle">					<div id="topmargin2">						<form>							<input title="skriv ett sök ord här." class="topinput" type="text" name="search" onblur="addText(this);" onfocus="clearText(this)" value="Sökord" />							<a title="Skriv ett sökord och klicka sen här för att söka." class="topa" href="" onClick="document.submit()">Sök</a>						<form>					</div>				</div>				<div class="topright"></div>			</div>		</div>	</div>	<div>		<div id="left">	<div class="margin10">		<p class="hp">Navigering</p>	</div>	<div id="mframe1">		<div id="mframe2">						<a title="Till start sidan." class="menua" class="onpage" href="index.php?m=1&md=mainpage">Start											<span class="sizemenua">∨</span></a>										<br />								<a title="Till start sidan." class="submenua"  href="index.php?m=1&sm=1&md=mainpage">En till startsida</a><br />							<a title="Sidans forum" class="menua"  href="index.php?m=2&md=mainpage">Forum											<span class="sizemenua">></span></a>										<br />							<a title="Ha inga submenyer nu." class="menua"  href="index.php?m=3&md=mainpage">No submenu								</a>								<br />							<br />		</div>	</div></div><div id="middle"></div><div id="right">	<div class="margin10">		<p class="hp">2009-06-24</p>	</div>	<div id="cframe1">		<div id="cframe2">			<div id="cframe3">			</div>			<div id="cframe4">				<a title="Kopiera länk adressen till din rss läsare för att få rss feeds." href=""><img alt="rss" src="pageparts/rss.jpg" /></a>			</div>		</div>	</div></div>	</div>	<div>		<p class="bottomCenter"><a class="bottoma" href="">Kontakta</a> <a class="bottoma" href="">Javascript</a> <a class="bottoma" href="">Cookies</a> <a class="bottoma" href="">RSS</a> Copyright © 2009</p>		<div id="bottomborder"></div>		<p class="bottomCenter">PAGE MODULE V.1 Created By CkruDeluX.COM</p>	</div></body></html>

Link to comment
Share on other sites

You can assign two classes to an element by separating them with spaces in the class attribute:
<a class="menubutton onpage">

Thanks it works now then i got them in the same class tag and separated with a space. :)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...