Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 830
  • Last Modified:

CSS - remove menu image separator from last link and also sub menus?

Hi,
I am having trouble trying to work out how to remove an menu image separator from the last menu link and also from the sub menus?

Your advice help and advice would be appreciated.

<html>
<head>
<script type="text/javascript" src="/ScriptLibrary/latest-jquery.js"></script>
<style type="text/css">

body{
background-color: black;	
}

#navbar {
   margin: 0;
   padding: 0;
   height: 30px; 
}
#navbar li{
   list-style: none;
   float: left; 
   text-align: left;
   font-size: 14px;
   
}
/* main top menu */
#navbar li a{
	display: block;
	padding-left: 20px;
	padding-right: 20px;
	color: #f3f3f3;
	height:30px;
	line-height:30px;
	text-decoration: none;
	margin-right: -10px;
	background-image: url(/images/menu_separator.png);
	background-repeat: no-repeat;
	background-position: right;  
}

#navbar li a:hover {
   color: #fff;    
   z-index:100;

}


#navbar li ul{
   display: none;    
   width: auto;     
   z-index:500;
   min-width: 160px;   

}
#navbar li:hover ul{
   display: block;
   position: absolute;
   margin: 0;   
   z-index:500;
   padding: 0; 
}

#navbar li:hover li{
   float: none;   
  	background-color: red;
	background-repeat: repeat;
}
#navbar li:hover li a{
   border-bottom: 1px dotted #CCC;
   color: #fff;    
   min-width: 160px;    
}


#navbar li li a:hover{
	background-color: #003300;
}




</style>

</head>
<body> 
      


<ul id="navbar">

<li><a href='#'>ABOUT US</a></li>
 
<li><a href='#'>CUTS & COLOURS</a>
    <ul>
    <li><a href='#'>Style Cuts</a></li> 
    <li><a href='#'>Up Styles</a></li> 
    <li><a href='#'>Straightening</a></li> 
    <li><a href='#'>Keratin Treatments</a></li> 
    </ul>
</li> 

<li><a href='#'>BEAUTY TREAMENTS</a>
    <ul>
    <li><a href=''>Threading</a></li> 
    <li><a href=''>Make Up</a></li> 
    <li><a href=''>Nails</a></li> 
    </ul>
</li> 

<li><a href=''>WEDDINGS & FORMALS</a></li> 

<li><a href=''>SPECIAL OFFERS</a>
    <ul>
    <li><a href=''>New Clients</a></li> 
    <li><a href=''>Regular Clients</a></li> 
    </ul>
</li> 

<li><a href=''>CONTACT</a></li> 
</ul>

</body>
</html>

Open in new window

0
sabecs
Asked:
sabecs
1 Solution
 
Randy DownsOWNERCommented:
Your CSS designates the image for all URLs in the list. Try adding an id that leaves that out. Then assign the last URL with the id
Example: <li#last><a href=''>CONTACT</a></li>

Similar to this - http://stackoverflow.com/questions/8488141/define-css-for-li-id


CSS without the image
#navbar li a last{ 
	display: block;
	padding-left: 20px;
	padding-right: 20px;
	color: #f3f3f3;
	height:30px;
	line-height:30px;
	text-decoration: none;
	margin-right: -10px;
}

Open in new window


Existing CSS
#navbar li a{
	display: block;
	padding-left: 20px;
	padding-right: 20px;
	color: #f3f3f3;
	height:30px;
	line-height:30px;
	text-decoration: none;
	margin-right: -10px;
	background-image: url(/images/menu_separator.png);
	background-repeat: no-repeat;
	background-position: right;  
}

Open in new window

0
 
Ishaan RawatDesigner | Developer | ProgrammerCommented:
This is not a good practice when you have CSS psuedo classes are there....

Try this...

#navbar>ul>li:last-child a,
#naavbar ul ul li a{
    background-image: none;
}

Open in new window


and then add this... if you want it to work for IE browsers also...

http://selectivizr.com/
0
 
Jagadishwor DulalBraces MediaCommented:
Not satisfied?

Change your css to:

#navbar li:hover li a{
   border-bottom: 1px dotted #CCC;
   color: #fff;    
   min-width: 160px;   
   background:none; /* add background none */
}

Open in new window


No for the last menu add css to the end of your style :

#navbar li:last-child a{
	background:none;
}

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Julian HansenCommented:
@IshaanRawat lets not actively support IE. The biggest problem on the Web is IE and if we developers bend over backwards to accommodate Microsofts nonesense they will continue to dictate the terms.

I make it a policy to specifically not spend 1sec on IE issues - if they come up I tell my clients that the problem is IE which is a browser on the decline and recently in the minority - especially 8 and below - and if any visitor complains then point them to anyone of the free standars complian browser.

Not to dis the work the selecivizr has done - but unfortunately tools like this are actually part of the problem by extending the life of software that should already have died a natural death.
0
 
Ishaan RawatDesigner | Developer | ProgrammerCommented:
Exactly. Thanks julianH
0
 
Jagadishwor DulalBraces MediaCommented:
@julianH Salute Your word Really
IE-Software that should already have died a natural death
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now