ayeedawg Posted July 31, 2012 Share Posted July 31, 2012 I have a set of links that are in one line next to each other that I spaced out using margin-right: 10px; but because of this, the line of links is off center. How can I make it perfectly centered? Link to comment Share on other sites More sharing options...
eTianbun Posted July 31, 2012 Share Posted July 31, 2012 I dont understand what you're talking about. Post the part you have problem with! Link to comment Share on other sites More sharing options...
ShadowMage Posted July 31, 2012 Share Posted July 31, 2012 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 More sharing options...
ayeedawg Posted August 3, 2012 Author Share Posted August 3, 2012 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:but 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 More sharing options...
ShadowMage Posted August 6, 2012 Share Posted August 6, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now