Click here to Skip to main content
15,888,015 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hai,

I want to set a background image. I used this css style.

C#
.menuItem
 {

 background-image : url(\My Project\images\menu_bg.gif);

 }



is it correct r not? please help me..
Posted
Comments
Ed Nutting 29-May-12 9:34am    
Is there actually a problem here? Just try putting the CSS in your page and see if it works... (Though for starters urls do not contain back slashes...)
Ed
ZurdoDev 29-May-12 9:49am    
Have you tried this? There are a lot of ways to add images as backgrounds but it will depend on what your menu is (divs, tables, etc).

1 solution

Setting background using CSS like:
CSS
background-image:url("Images/MenuStatic.gif");

is perfectly fine and should work. Try out.

Make sure that the URL used is valid and image is located at the specified location.
 
Share this answer
 
Comments
JilRose 31-May-12 7:24am    
this is very helpful. But the image only set for top of the menu, not set for sub menus. how to set the same image for sub menus?
Sandeep Mewara 31-May-12 7:45am    
Define css for submenuitem and then try to apply for it too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900