64 thoughts on “Center Header Block Items (3.1/3.2)

  • scanFOAM.org

    I’m on customizr pro and not good with css yet. My issue is with the navbar menu which isn’t centered. It looks fine on the desktop, but I want it to span the width of the screen on smaller displays where it keeps aligning left.

    Troys suggestion sounded elegant, but it breaks the social icons and the menu onto two lines instead of one.

    Site is: scanfoam.org.

    Any suggestions would be great.

  • Troy

    Skip the snippet when centering the _horizontal_ menu on your site. The better practice is always good CSS. Make sure your menu is aligned to the left. Aligning right will open up a float: right rule we don’t want.

    Drop the following in your Advanced-Options > Custom CSS editor in _Customize_ and Flexbox to the rescue. The following code centers the nav bar and the nav items for the horizontal menu. The media rule applies the flex directive just to the horizontal menu and before the vertical menu can take over.

    This works and it’s not going away soon.

    @media (min-width: 980px) {
    display: flex !important;
    justify-content: space-around !important;
    .menu-primary-container ul {
    display: flex !important;
    justify-content: space-around !important;

  • Angelo

    hi, i coded like this snippet says but, if you have the browser page at 1200px of weight the menu is correctly centered but if i resize the windows to a 1920px width the menu … slides a bit to the left… am i doing anything wrong?


  • Hezy

    I tried this filer with version 3.3.26 and I’ve noticed that function tc_set_logo_title_layout override the parameters $_classes sent to the function.

  • Monique

    Thank you for this great theme. It’s my favorite one.
    I just have one thing I can’t manage. And that’s to centre the menu without a logo. So I don’t want the logo at the menubar, but I see there some space for it. On a 13” it looks ok but on a widescreen it doesn’t.
    I hope you can help me.

  • Cil14

    I just add the code (function and css) for version 3.2.10 but I don’t see any change in my menu. Please help me.

  • Mike

    I followed this and it doesn’t seem to do anything on the live site. Strangely if I go to customize in Appearance the menu shows as centered in there. It just doesn’t show centered on the live site.

      • Radu Cosmin Cristianciuc

        Hi Nicolas,
        So I thought it must be but..
        I try the 3.2 version but nothing happened. I will tray again later.

  • Sean K Young

    I am now getting the implode error on tc_logo_class

    add_filter( 'tc_logo_class', 'rdc_logo_class' );
    function rdc_logo_class() {
    return 'brand span12';

  • Dana

    I understand how to copy and paste but where do I find the
    Child Theme style.css ?? Can anyone give me easy instructions on how to change the style.css I want to center my menu items! please help!

    • Nicolas

      Hi Dana,
      if you need to make minor CSS changes to your website, you may consider using the custom CSS feature.
      in your WP admin, navigate to Appearance > Customize > Advanced Options > Custom CSS
      Then copy your CSS code here and it will be instantly applied to your website preview.
      Hope this helps!

  • Dave Bardell Post author

    Many apologies for the snippet failing after the 3.2.1 update. I am working on an Update and will publish as soon as possible.

    In the meantime, I suggest you revert to the

  • Briana Reese

    I need a brain that is smarter than mine- please 🙂

    Put this in my child themes functions.php:

    And I’m getting this rad error now:

    I’m wallowing in pitiful right now, please help <3

  • Bree

    SO this super rad code works BUT I’m getting a couple of errors.

    Using just this code:

    And receiving these errors:

    Is this because of an update maybe? The parent theme is fresh and unedited..

    Any help would be *greatly* appreciated 🙂

  • Dave Bardell Post author

    Have updated CSS Step 4 with tighter specificity .navbar-wrapper .navbar.notresp, and added Start/End comments to make copy/paste area more obvious.

  • Keith Brodie

    Is there a code snippet. or place to adjust the navbox/header re-alignment characteristics? Specifically, everything looks great, but when you resize the screen slightly smaller, or use the zoom function to app. 125%, the navbox drops and there is a gap between it and the top of the screen. Yet the logo and social icons stay up at the top. here’s my site for reference: http://www.pmtrainingclass.com

    • Dave Bardell Post author

      Hi Keith.

      You need to add some @media code to make any adjustments you need. See this Snippet for more information.

      If still stuck, I’d suggest the Forum would be a better place to get a solution for this, with a much wider audience to help fix problems. And please include a link to your Site.

  • Kelsi

    Thanks for this fix Dave! Everything worked for my navigation but I’m having trouble getting my logo to be centered and enlarged. I created a child theme and I think I copied the code into the right place [Appearance >> Editor] but it’s still not working. I know very little about HTML and CSS so I appreciate the help!

    My site: oneelevenmissoula.com

    • Dave Bardell Post author

      Hi Kelsi, it looks like you fixed your problem?

      If not, I’d suggest the Forum would be a better place to get a solution for this, with a much wider audience to help fix problems. And please include a link to your Site.

  • Brandi

    This worked perfectly for me, with 1 tiny exception:

    All of the other functions in my dashboard are fine except for the “customize” option – I get an internal server error. I don’t know enough about php to be able to troubleshoot (besides removing all of the code mentioned above). I did have a bit of code already in my child functions.php file – could there be some conflict?


    • Dave Bardell Post author

      Thanks Brandi. I’d suggest the Forum would be a better place to get a solution for this, with a much wider audience to help fix problems. And please include the link to your Site.

    • Dave Bardell Post author

      Thanks to @If designs (daniel) for pointing out error in Step 1.

      Thanks to @Norman Fetter for pointing out error with Social Icons (Still under investigation – a weird one!). I’ve highlighted the code to avoid until fixed.

  • Cherie Benjamin

    Just as a note in the functions.php above there is an extra curly bracket at the end that when someone copies and pastes the code it renders the theme not to work.

  • Katie

    Hi, I created my own css class for a right border so that I could apply it to ONLY the first three items on my menu and not the last one (because it looks weird to have a right-border after the last item, at least on my design).

    This theme has a great feature in the Appearance>Menus section of the Dashboard where you can apply CSS directly to an individual menu item (just make sure you select CSS classes in “Show advanced menu properties” in Screen Options tab at the top of your Dashboard). So just create your new class in your child theme css and then add that class to the CSS Class window for the relevant menu items.

    You’ll have to adjust the class back to remove the border for screen sizes below 979px if you don’t want borders on your mini-menu.

  • SebvandenBerg

    Hi everyone,
    first of all: my compliments for a superb theme. And also for the above snipet, just what the doctor ordered!
    The only problem that I am facing with it: is that I want to have vertical lines between the menu items. I’d figured a simple border-left and border-right would do the trick. But I have been trying to apply that to all css classes that I could imagine had something to do with it, but NO luck. I am getting desperate.
    Most logically, I had thought it would need to be applied to ‘.navbar .nav > li > a’. But that doesn’t work.
    Can anyone help? Which CSS class would I need to put borders on?
    Many thanks!

  • Buddha

    I have created a Child Theme, and the parent theme is running the 3.0.15. Now, from the snippets above, I used the one titled 3.0.14 update in the functions.php file within the child theme directory.

    1. The logo is centered but this center alignment is not perfect. Please check here: http://projectparampara.com
    2. Also, the menu is not center aligned. It is still left aligned.

    Please suggest a way to solve these two issues.

    • Dave Bardell Post author

      Had latency problems accessing your site, leading to Firefox crashing. I did see your site briefly. There was no logo loaded, and a blank menu/navbar.

      I’d suggest the Forum would be a better place to get a solution for this, with a much wider audience to help fix problems. And please include a link to your Site.

  • Katie

    Thanks for getting back to me so quickly Dave. To anyone who has the same problem I was having, we figured out that there was an overlapping Div that must have been blocking the link to “back home” embedded under the logo. I used this css to fix it:

    This is a great theme and appreciate the support!

  • Larry

    I have installed a plugin that has messed up the way the menu renders. I believe it is because of the order that the references are now populated in the header. For the life of me I can’t find the function that is used to created the tags so I can reorder them. Any help you can provide is greatly appreciated.


  • Ruud


    Is it possible to get the navbar on 100% width?
    Because the right site of the navbar keeps on getting a white background.
    I want to get it from left to right with a grey background or image.
    Which code can I use in my child theme?


    • Dave Bardell Post author

      Change the function.php above which removes span9 from navbar-inner to:

  • Katie Sutton

    Hi, thanks for this snippet and all of them! Very helpful. However, I notice that adding the PHP snippet to remove the span 9 seems to cause the “Go Home” hyperlink functionality of the logo to stop working. Any way we can get that back and still have a centered menu?

      • Katie

        Hi – Thanks Dave – I do have a lot of custom CSS so that well could be, although as soon as I take the new Span 9 function out it works again. Is there a way to send you a link privately? Site is for a client and they do not want it public yet.

        • Norbert

          Hey Katie, it you still have this problem in version 3.2. I had the same problem and solved it by setting .navbar-wrapper from position: relative back to position: static. Perhaps this helps.

  • Cari

    Hi 🙂

    I was wondering if I could center the menu below a large image in the header with this theme. I’d love to continue using this for various website!!

    I found this snippet but it appears it centers the items within the navbar vs. centers the navbar – am I understanding wrong?

    http://www.jeanneesti.com/test is where I’m starting to work (STARTING being the keyword for this one!)

    • Dave Bardell Post author

      Most of these Snippets are tested standalone, so it is possible that when added to other CSS code they don’t work quite as intended. I’d suggest the Forum would be a better place to get a solution for this, and include a link to your Site.

      Cari, I recognise you from the Forum so I hope you resolved this!

      Thanks for using Customizr.

  • kevin

    Hi everyone, I wonder if you can help…. I can’t find it listed unless I’ve missed it. I love this theme but can’t quite get my head around why the logo is above the menu bar, it seems to be on the same horizontal space as the menu on all of the other sites with the customizr theme. Am I missing something and can this be resolved with a snippet?

    Thanks in advance.


    • Dave Bardell Post author

      John & Kevin, I suggest you try the Forum for specific problems you have, giving a link to your site if you can. Refer to this Snippet if you think there’s a problem in it.


  • John

    Hey Dave,

    This snippet centre is awesome! Thank you so much for putting all of these tips here.

    I was wondering if you could help me out with the header? I want to have the logo and menu line up with the width of the rest of the front page but have no idea where to start. Could you perhaps give me some pointers? I’ve only just started building my site and I’m trying to learn CSS but I’ve no idea which tags to look for within the code.

    Many thanks again,


Comments are closed.