Solved

Adding a partial border on list item but not on the first element

Posted on 2014-02-18
8
244 Views
Last Modified: 2014-02-18
Hi experts,
I have a top menu bar created with a list and I want separators made of a partial border.
So far I have this:
#TopLinks .nav > li > a:after{content:""; background: #a8a8a8; position: absolute; bottom: 5px; left: 0; height: 50%; width: 1px;}
This is working great, but I don't want the first element to have a border.
I've tried combined (not)first-child with the previous style, but I can't make it work.

That's what I have so far with the style above:
 topbarYou can see that the first element has a border on the left, which I don't want.
Any help appreciated, thanks.
0
Comment
Question by:hqdev
  • 3
  • 3
  • 2
8 Comments
 
LVL 18

Accepted Solution

by:
ChetOS82 earned 500 total points
ID: 39867562
#TopLinks .nav > li:first-child > a:after{width:0px;}
0
 
LVL 58

Expert Comment

by:Gary
ID: 39867565
#TopLinks .nav > li > a:not(:first-child):after{...}
0
 
LVL 18

Expert Comment

by:ChetOS82
ID: 39867578
My only concern with :not is that it isn't supported on IE8 or earlier.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 

Author Comment

by:hqdev
ID: 39867589
ChetOS82, this is working!
Sorry Cathal, but this is not working.
0
 

Author Comment

by:hqdev
ID: 39867597
It's for an intranet, so we are in control of browsers and we will use only the latest, it's ok, if it's not IE8 compatible.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39867629
Yeah it should have been

#TopLinks .nav > li:not(:first-child) > a:after

If you are still writing code to support IE8 you need a reality check
0
 

Author Comment

by:hqdev
ID: 39867642
Just for fun, I've tested your last entry Cathal and it's working, sorry I've already close the case.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39867651
NP, accepted solution is perfectly valid.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

839 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