Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

"Coding the Header and Footer" - My Navigation Menu is Vertical!

My code matches Zac's from everything that I can see. After his changes in this section, but nav menu loses the bullets as it is supposed to. The font is correct. The lines are there. BUT, the menus is stacked vertically rather than being in line horizontally. I've seen suggestions online concerning making a nav menu horizontal, but we're so deep into this custom theme, that the solutions either don't seem to work or don't apply to how we're doing things.

I appreciate any help on this issue!

8 Answers

In the CSS styles did you inline the bullets?

I just got it horizontal by replacing block (I think) with inline. but now it's left aligned. I guess I just center it at this point somehow? Or am I going down a bad path?

/* ========================================================================== Header ========================================================================== */

header { margin: 4% 0 0 0; }

nav { display: -webkit-box; -webkit-box-orient:horizontal; padding: 2% 0; border-bottom: 1px solid #e6e6e6; border-top: 1px solid #e6e6e6;
margin: 2% 0 2% 0; }

nav a { font-family: 'GoudyRegular'; display:inline; #################################### -webkit-box-flex:1; text-align:center; font-size: 1.25; color: #666; }

Note the "###########" where supposed to indicate where I made the change. When I posted, all of the code ran together. Ignore the "##########".

I added a text align: center to the nav section. That centered it, but in Zac's it's evenly spread out.

If you are attempting to center the navigation bar at the top of the page, you will need to center the wrapping div using CSS. Great link on W3C about this:

http://www.w3schools.com/css/css_align.asp

There are several options with varying browser compatibility.

If you want all of the links to be evenly distributed you will need to use left floats and margins. See the "Floating List Items" section here:

http://www.w3schools.com/css/css_navbar.asp

Correction: floats and widths.

Floating requires a "block" display. When using "block" display, this nav menu will only go vertical. Only with inline does the menu go horizontal. I think the code I'm dealing with now is different than what Zac worked with in the tutorial or something. It's frustrating that it won't work.

The float left replaces the in-line and should make the vertical list horizontal. See example of code and output on W3C:

http://www.w3schools.com/css/tryit.asp?filename=trycss_navbar_horizontal_float

I appreciate your help, but for the code that I'm working with for this Treehouse tutorial, it is just making things worse.

/* ========================================================================== Header ========================================================================== */

header { margin: 4% 0 0 0; }

nav { display: -webkit-box; -webkit-box-orient:horizontal; padding: 2% 0; border-bottom: 1px solid #e6e6e6; border-top: 1px solid #e6e6e6;
margin: 2% 0 2% 0; text-align: center; }

nav a { font-family: 'GoudyRegular'; display:inline; -webkit-box-flex:1; text-align:center; font-size: 1.25; color: #666; }

That's my current code. When I make the changes that you specified--which I know are usually right--it pushes the menu over to the left (vertical now) with other page content smushed up against it.

Try this:

header { margin: 4% 0 0 0; }

nav { display: -webkit-box; -webkit-box-orient:horizontal; padding: 2% 0; border-bottom: 1px solid #e6e6e6; border-top: 1px solid #e6e6e6; margin: 2% 0 2% 0; text-align:center; list-style: none; }

nav li { float: left; }

nav a { display: block; width: 60px; font-family: 'GoudyRegular'; -webkit-box-flex:1; text-align:center; font-size: 1.25; color: #666; }

I hate to break it to you, but it's still not working. I recommended that Treehouse focuses on version control of the tutorial materials and possible adds a screen next to the video displaying what code is currently in use. It's just too confusing typing while looking at the video, and there's no way to know where the disconnect is on an issue like this.

As far as your edits, it still produced a vertically stacked menu. I appreciate your help. I'm sure you're as frustrated as I am.

Can you paste in a code block the current HTML you are using. I need to see the navigation structure specifically.

Michael: PLEASE FOR THE LOVE OF GOD don't link students to W3Schools pages. Their sites are incorrect, ad laden, and generally worthless for any purpose. MDN is a far superior resource and just as simple to find stuff on.

http://www.w3fools.com/

--

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi!

Can you post up the code for your header file and CSS file? Make sure to follow this formatting guide: https://teamtreehouse.com/forum/how-to-type-code-in-the-forum

If you're able to put the site up online that would be best, but I understand that might not be possible.

Also, I hear you on the version control and better tracking of coding changes. The next WP project does a much better job on this.

It's funny. I had worked around the problem by making the list "inline" via the CSS. But I wasn't satisfied. So, right before you replied, I was in the process of converting the list to a <ul> without using variables. But I decided to revert back to the Treehouse code, since you're helping me out. And now, even with inline in the CSS, the menu is vertical AND has bullets... I don't get it! Haha!

My website is live at www.coreydeanstone.com

Fixed the bullets---had false in ' 's.

Still have the CSS as inline for the nav menu. Any of the block formatting from the tutorial made stuff go all over the place.

My formatting is really giving me fits. I'm almost certain my code is = your code, and yet my grid_12's never seem to work like yours did. It's really frustraring. I appreciate any help ASAP!

Did you find the issue with your formatting? I checked your website link and the navigation bar looks horizontal.

.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

I may be jumping on this a little late, but it seems that the nav looks good to me?

Oh, I went with a new template and have been working away from the tutorial for a couple of days now. I appreciate the tutorial. It gave me a really solid foundation for working on my own template, but I had to stop about 70% of the way through. There were just too many things that my code wasn't doing but yours was. As a viewing tutorial, though sometimes fast, I give it an A! But as a do-it-yourself follow-along, it was difficult to get some of the functionality to work. No hard feelings, but as far as WordPress goes, I'm flying solo for a little while. I might come back and watch the rest in a few days. Thanks for the assistance!

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

I appreciate the feedback man, and the upcoming videos will hopefully be much better in that regard. Best of luck and let us know if we can help with anything!!!

Jamie Homewood
Jamie Homewood
1,790 Points

I've got the same issue, and must be something wrong with the way WordPress now deals with menus (I'm using 3.6.1). If I open the 'wp-theme-development-stage-05' index file my menu displays vertical with bullets.

inside header.php

$args = array(
                              'menu' => 'main-menu',
                              'echo' => false
                              );

                echo strip_tags(wp_nav_menu( $arg ),'<a>');

Source Below:

<nav>
<div class="menu-main-menu-container">
<ul id="menu-main-menu" class="menu"><li id="menu-item-24" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-12 current_page_item menu-item-24"><a href="http://localhost/wordpress/jones/">Home</a></li>
<li id="menu-item-25" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-25"><a href="http://localhost/wordpress/jones/?page_id=4">About</a></li>
<li id="menu-item-26" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-26"><a href="http://localhost/wordpress/jones/?page_id=6">Blog</a></li>
<li id="menu-item-28" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-28"><a href="http://localhost/wordpress/jones/?page_id=8">Work</a></li>
<li id="menu-item-42" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-42"><a href="http://localhost/wordpress/jones/?page_id=40">Recipes</a></li>
<li id="menu-item-27" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-27"><a href="http://localhost/wordpress/jones/?page_id=10">Contact</a></li>
</ul>
</div>                
</nav>

and CSS from style.css

nav {
display: -webkit-box;
-webkit-box-orient:horizontal;
padding: 2% 0;
border-bottom: 1px solid #e6e6e6;
border-top: 1px solid #e6e6e6;  
margin: 2% 0 2% 0;
}

nav a {
font-family: 'GoudyRegular';
display:block;
-webkit-box-flex:1;
text-align:center;
font-size: 1.25;
color: #666;
}
Jamie Homewood
Jamie Homewood
1,790 Points

wp_nav_menu:

$args = array(
    'echo' => false,
            'depth'           => 1,
             );

                echo strip_tags(wp_nav_menu( $args ),'<a>');

Edited my CSS like this and all seems well

nav {
wisth:100%
display: -webkit-box;
-webkit-box-orient:horizontal;
padding: 2% 0;
border-bottom: 1px solid #e6e6e6;
border-top: 1px solid #e6e6e6;  
margin: 2% 0 2% 0;
}


nav a {
font-family: 'GoudyRegular';
display:inline-block;
-webkit-box-flex:1;
text-align:center;
font-size: 1.25;
color: #666;
padding:0 55px 0 55px;

}

I'm not sure how to make it responsive or to react to different amounts of menu items so the spacing changes etc. Any advice or changes gladly received:) Keep up the good work fellas;)

DON FLOYD
DON FLOYD
3,711 Points

That does work although its no good when it comes to being responsive as you said

I am still having the issue with the nav showing vertical in every browser except chrome.

and as with Corey I have issues with the grid system. I have a logo with a grid of 2 title with a grid of 8 and another logo grid of 2 . so 2+8+2 = 12 that works no bother.

I add in the nav with a grid of 12 and the nav gets squashed into the right hand side of the 2+8+2 = 12 element I change it to grid 11 and it works????

I have been struggling for a few days with this now and would really appreciate some help. I have looked around the net and cannot find the answer!

http://ubuntuwpress.cloudapp.net/test/wordpress/

<head>

        <title>

            <?php

                wp_title( '-', true, 'right' );

                bloginfo( 'name' );

            ?>
        </title>

        <meta name="viewport" content="width=device-width, initial-scale = 1.0">
        <?php wp_head(); ?>
    </head>


<body>


    <div class="container clearfix">

        <header>
    <div class ="title" >
                <div class="grid_2  omega">

                    <img src="http://ubuntuwpress.cloudapp.net/test/wordpress/wp-content/themes/wpportfolio/images/kano.jpg" >
                </div>




    <div class="grid_8 title omega">
                            <hgroup >
                                <h1> 
                                <br>

                                <a href="<?php bloginfo('siteurl'); ?>"><?php bloginfo('name'); ?></a>

                                </h1>
                                <h2>
                                <?php bloginfo('description'); ?></h2>
                            </hgroup>

    </div>

                <div class="grid_2  omega">

                            <img src="http://ubuntuwpress.cloudapp.net/test/wordpress/wp-content/themes/wpportfolio/images/kano.jpg" >
    </div>  

</div>

    <div class=" grid_11 omega  ">
                        <nav>
                            <?php
                                $args = array(
                                    'menu' => 'main-menu',
                                    'echo' => false
                                );

                                echo strip_tags(wp_nav_menu( $args ), '<a>');

                            ?>
                        </nav>
        </div>
            </div>          

        </header>
Brian Eder
Brian Eder
1,008 Points

Still no response to this? Or has the thread moved?