Navbar border left & right issue

Nick M

Well I am truly stumped today, I am trying to recreate this Navbar:

http://www.autotrader.co.uk/

Now if you look at it, it has borders-left and borders-right for the "Buying" link. After digging about in the CSS I have worked out how they have made that possible. They have this HTML:

<ul class="navmain_holder">
</ul>

The developers have added a border-left to that element to create the border at the start of the nav bar.

Now if you take a look at this live header example of my site:

http://www.dealerbyte.co.uk/

The border is set to the left however if you look at the "Get Finance" link I can't add a right-border to it because then all the other elements will get that border which will cause some borders to appear 2px thick instead of one and as I am using Bootstrap the responsive CSS stops me from approaching this problem in some ways.

I'm sorry I haven't really explained my problem all that well hopefully someone will understand, any help will be much appreciated :)

Clint Powell

You can select the last element with the following selector:

ul.nav > li:last-child {
  border-right: 1px solid #475d88;
}

It selects only the last li element. Good luck!

EDIT here's a demo fiddle from Harry: http://jsfiddle.net/hari_shanx/D2JzN/

EDIT as Pete has pointed out, you could also add the border-left just to the outer ul element and apply border-right to all the li elements. It's also worth pointing out that if you want to support IE8 the last-child selector is not supported I believe. So you might have to go this route, but from my testing it looks like you aren't trying to support IE8, which is probably better for your sanity. :)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Navbar border left & right issue

From Dev

Bootstrap navbar left to right

From Dev

Animate border left to right

From Dev

Thick border on the right and on the left

From Dev

bootstrap navbar floating left and right

From Dev

border setting for the top right left

From Dev

Animating bottom border (left to right)

From Dev

Animating bottom border (left to right)

From Dev

I'm using border-left border-right as dividers in my site's navbar. I want to know how I can have them centered in the navbar

From Dev

Bootstrap 3 Navbar Collapse menu at Left for left and right navbar items

From Dev

Left And RIght Arrow Key Issue

From Dev

Animating right to left issue in jQuery

From Dev

pygame moving left and right issue

From Dev

Bootstrap Navbar - Menu Items border issue

From Dev

Navbar align part right part left errors

From Dev

Bootstrap navbar right side falls under the left

From Dev

Horizontal navbar with float:left;none;right items

From Dev

Remove border on far left and far right

From Dev

Overlapping table element left and right border

From Dev

Sass border top, left, bottom, right

From Dev

Border drawable for a view in Android with margins on left or right

From Dev

Way of shortening border left right bottom?

From Dev

On hover animate bottom border left to right

From Dev

<tr> removing border on left and right only

From Dev

Sliding border from right to left using CSS

From Dev

Left and Right side container border not the same

From Dev

Sass border top, left, bottom, right

From Dev

Border-bottom from left to right

From Dev

CSS - left border of button is rounded on the right side