Solved

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

Posted on 2013-05-24
6
808 Views
Last Modified: 2013-05-25
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
Comment
Question by:sabecs
6 Comments
 
LVL 29

Expert Comment

by:Randy Downs
ID: 39196120
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
 
LVL 10

Expert Comment

by:Ishaan Rawat
ID: 39196150
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
 
LVL 15

Accepted Solution

by:
Jagadishwor Dulal earned 500 total points
ID: 39196195
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 55

Expert Comment

by:Julian Hansen
ID: 39196207
@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
 
LVL 10

Expert Comment

by:Ishaan Rawat
ID: 39196214
Exactly. Thanks julianH
0
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 39196241
@julianH Salute Your word Really
IE-Software that should already have died a natural death
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question