Solved

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

Posted on 2013-05-24
6
804 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 9

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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 54

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 9

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

816 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now