Solved

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

Posted on 2013-05-24
6
819 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 30

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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
LVL 57

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
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).

687 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