Jump to content

Center Links with a Right Margin


ayeedawg
 Share

Recommended Posts

If I understand correctly, you need to remove the margin from the last link in your list. Give it an id or use inline styling and set the right margin to 0. You could also use the :last-child psuedo-class but that's CSS 3 and won't be supported by older browsers.

Link to comment
Share on other sites

If I understand correctly, you need to remove the margin from the last link in your list. Give it an id or use inline styling and set the right margin to 0. You could also use the :last-child psuedo-class but that's CSS 3 and won't be supported by older browsers.
That sounds like it should work, but if I make an id then the last link goes to the next line, and the inline styling didn't seem to do anything... Let me try to explain more clearly. I have a line of links that looks like this:xukqt.jpgbut as you can see, it's off center by 15px because each link has a right-margin. This is what I have (removed the urls):
#navigation a {margin-right: 15px;} <div id="navigation"><a href="/">▵</a> <a href="">⌘</a> <a href="">?</a> <a href="">❥</a> <a href="">✿</a> <a href="" style="margin-right: 0px;">©</a></div>

Link to comment
Share on other sites

Hmmm...That should work. Try clearing your browser cache. If that still doesn't work, try adding !important to the inline style like this:style="margin-right: 0px !important;" Usually, I do it the other way around. I'll give the elements a left margin and use the :first-child psuedo element to remove the margin. The :first-child selector is supported in all major browsers (including all but the most ancient ones).

a { margin-left: 15px; }a:first-child { margin-left: 0px; }

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...