Solved

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

Posted on 2013-05-24
6
795 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 51

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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 …
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 add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 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

10 Experts available now in Live!

Get 1:1 Help Now