Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining a style sheet and an inline style 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I have a site which is created dynamically and each page has a menu at the top of the page. The menu is a container div which contains a div for each menu item. The container has a background image which I want to change depending on which menu item is selected.
This code puts one of the background images into the container and works ok. (This is set up for the home page)
Code:
.menu {
	width:980px;
	height:40px;
	font-size:12px;
	color: #56789a;
	font-family: Verdana, sans-serif;
	text-decoration: none;
	font-weight:normal;
	text-align: left;
	background-image: url("menu/men_home.jpg");
}
.menu a  {
	font-size:12px;
	font-family: Verdana, sans-serif;
	text-decoration: none;
	font-weight:normal;
	color: #56789a;
}
.menu a:hover {
	font-size:12px;
	color: #FF0000;
	font-family: Verdana, sans-serif;
	font-weight:normal;
	text-decoration: none;
}
Is there a way of combining this data with an inline style in order to change the background image only, but leaving the other attributes active?
Once the div is declared, can I change an attribute within it?


Keith
 
Why not use Javascript in order to change the background style on the fly on mouseover on every menu item?

 
Sorry Dan
Not too sure about your solution.
How would I syntax the code?
Code:
<div class="menu" style="background-image: url(menu/men_home.jpg);"

.... content

</div>

Keith
 
Hmmm.. I might have got the wrong idea about what you want to do.

Did you want to be able to change the background image on hover of the menu items, or have 1 different per page / selection?

I assumed the latter, but I could be wrong?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top