Grow your CSS skills. Land your dream job.

Logo Centered in Nav

  • # September 9, 2012 at 10:16 pm

    Hi,
    I’m trying to do an assignment for my class and I’m stuck on this logo being centered within navigation. I’ve been working on getting this right for hours and it’s driving me crazy.
    I searched the forums and found this:
    http://css-tricks.com/forums/discussion/18095/how-to-make-header-nav-divided-by-logo/p1

    The two examples aren’t actually centered when I try it though. The right side is kind of stuck to the logo and it moves when I resize the window.

    Does anyone know how to center a logo in the middle of a nav bar? I’d like the nav bar to fill the page like in the picture.
    Thank you in advance for your help.

    Image and video hosting by TinyPic

    # September 9, 2012 at 10:58 pm

    I assume you’re using an unordered list (ul and li’s)? If so, what I’ve done in the past is just have the logo as one of the list items with its own class (like “logo” for example).

    # September 9, 2012 at 11:38 pm

    You know what, Andy, I don’t think I’ve ever thought to do that before – pretty smart!

    # September 10, 2012 at 12:19 am

    Thanks. That’s what I’m doing, sort of. I applied the class as a logo and then had the logo as a background image. All the nav is spaced out well and the logo is centered within it, but what I keep running into is the whole nav itself not being perfectly centered. I’d show you my code but I’m not sure how to put that in here. If I paste in my code (if you could tell me how) will it help you to help me? I want to learn from whatever mistake I’m making so I know how to do this in the future.

    Thanks!

    # September 10, 2012 at 2:42 am

    You can put your HMTL & CSS in Codepen.io and let us have a look.

    # September 10, 2012 at 7:05 am

    @thedoc – I’m sure some SEO expert would say it’s madness or something, but at the end of the day – it works and means cleaner code.

    # September 10, 2012 at 8:25 am

    From an SEO standpoint there is nothing wrong with putting the logo in a list item as its still readable by Google and other search engines, however a screen reader would have a field trip with it since they read the source from top to bottom, left to right.

    Since the logo would be in a list item a screen reader would go

    - Home
    - Stats
    - Schedule
    - Michigan

    etc…

    # September 10, 2012 at 8:32 am

    Yes but isn’t that correct? I mean it is in the middle so screenreaders would read it correctly based on the layout. Sighted users would see Home/Stats first too.

    Additionally – you’ve also got the alt-tags available if the image is physical rather than a CSS background (I always make them an actual image for this purpose rather than css background). So you could have “Michigan Logo, we do blah blah blah”.

    # September 11, 2012 at 1:02 am

    Thanks for all your comments. I wasn’t thinking about SEO…and probabyl should. Some students in my class are trying to figure this centered logo situation out and haven’t gotten it yet. This is the closest I came and it’s a pretty pathetic attempt. Any ideas?

    http://codepen.io/anon/full/mrDed

    # September 11, 2012 at 1:03 am

    probably*

    # September 11, 2012 at 3:21 am

    There you go : http://jsfiddle.net/P7PNj/1/.

    # September 11, 2012 at 4:26 am

    @Miela84 – for your logo “a” element make sure you add title=”description goes here” somewhere for screen readers. Otherwise they won’t be able to experience that there is a logo there.

    # September 11, 2012 at 4:40 am

    Thanks HugoGiraudel, but I’m wondering, when I re-size the window the whole nav area isn’t centered. That’s the problem I’ve been having. It’s shifted more to the left. Am I missing something?
    Thanks for that Andy, I’ll make sure I’ll add it next time.

    # September 11, 2012 at 4:50 am

    Miela, re: your sizing/alignment issue – all of the LI (list items) are currently floated left, so they’re stacking, all you need to do is work out how big your container is and then add padding to each to fill evenly and that bad boy will be ready for dinner.

    # September 11, 2012 at 7:46 am

    There : http://jsfiddle.net/P7PNj/2/.

Viewing 15 posts - 1 through 15 (of 32 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".