• Resolved cooljosh3k

    (@cooljosh3k)


    When I try to view my site in` different resolutions and on different devices, the menu items I have always tend to be scrambled up into “random” locations.

    Any ideas on what I can change to fix this and have everything act like normal?

    Here is my slightly modified style file: https://www.tf2tightrope.com/wp-content/themes/bouquet/style.css

    My website is TF2TightRope.com, but in case the issue does not appear on your resolution/device I have taken a screenshot: http://imgur.com/wsBj5zn

    Any help on this issue is greatly appreciated.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Hi there – Bouquet comes with a responsive menu, as you can see on the demo: https://bouquetdemo.wordpress.com/

    It looks like you’ve overwritten the responsive menu when making your modifications. You’ve also changed the stylesheet directly, which means that your tweaks will be overwritten every time the theme is updated. I’d strongly recommend that you move out your CSS changes into a custom CSS plugin instead.

    An easy way to add custom CSS is to install the Jetpack plugin and activate the Custom CSS module. You’ll then add your custom CSS in the new stylesheet editor that’ll appear in your dashboard, under Appearance > Edit CSS. You could also install a standalone custom CSS plugin if you prefer.

    If you modified other files in addition to style.css, the recommended route is to make a child theme. Here are some guides in case you haven’t made one before:

    http://codex.wordpress.org/Child_Themes
    https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/
    http://vimeo.com/39023468

    Keeping your theme up-to-date is important so you’ll get all the latest bug and security fixes, as well as keep the theme compatible with the latest version of WordPress core.

    When you make your CSS tweaks to the menu, be sure to use media queries so they don’t overwrite the theme’s responsive menu. You can learn more about using media queries that target certain screen sizes here:

    http://en.support.wordpress.com/custom-design/custom-css-media-queries/
    http://css-tricks.com/snippets/css/media-queries-for-standard-devices/
    http://webdesignerwall.com/tutorials/responsive-design-with-css3-media-queries

    By restricting your changes only to the non-mobile menu using media queries, you’ll ensure your menu is readable on all devices.

    I hope this points you in the right direction!

    Thread Starter cooljosh3k

    (@cooljosh3k)

    This is the kind of thing that I was wondering about previously. Thanks for the information and links.

    Moderator Kathryn Presner

    (@zoonini)

    My pleasure.

    Thread Starter cooljosh3k

    (@cooljosh3k)

    I was able to copy mostly everything over into a child theme, but sadly the navigation menu still remains all messed up

    Moderator Kathryn Presner

    (@zoonini)

    Glad you got a child theme set up.

    This portion of your child theme’s stylesheet looks to be the culprit. If you remove it using a browser inspector the menu display returns to normal.

    #access {
         box-shadow: 1px 5px 5px 5px rgba(0, 0, 0, 0.2);
         float: right;
         width: 100%;
    }
    
    #access a {
         font: 800 24px/0.9em Verdana,sans-serif;
         padding: 0.5em 0.9em;
         text-shadow: -1px 5px 1px rgba(0, 0, 0, 0.2);
    }
    
    #access ul ul a {
         padding: 0.5em 1em 0.5em 0.5em;
    }
    
    #access ul li:hover > ul {
         display: block;
    }

    I also noticed that you’ve accidentally enqueued two copies of your theme’s stylesheet in your child theme, which should be fixed. If you view your browser source you’ll see this:

    <link rel='stylesheet' id='child-style-css'  href='https://www.tf2tightrope.com/wp-content/themes/bouquet-child/style.css?ver=4.5.3' type='text/css' media='all' />
    <link rel='stylesheet' id='bouquet-css'  href='https://www.tf2tightrope.com/wp-content/themes/bouquet-child/style.css?ver=4.5.3' type='text/css' media='all' />

    I’d suggest checking your child theme setup to make sure you’re not enqueuing your stylesheet twice.

    Thread Starter cooljosh3k

    (@cooljosh3k)

    Ah, I see. I would never have figured that out.

    I updated those lines to now be:

    #access {
    	box-shadow: 1px 5px 5px 5px rgba(0, 0, 0, 0.2);
    	width: 100%;
    }
    #access a {
    	font: 800 24px/1.625 Verdana, sans-serif;
    	text-decoration: underline;
    	text-shadow: -1px 5px 1px rgba(0, 0, 0, 0.2);
    }
    .genericon {
    	text-decoration: none;
    }
    .dashicons, .dashicons-before::before {
    	text-decoration: none;
    }

    I am unsure how to fix that issue of the two enqueued copies. At a rough guess, would I change my function file from:

    <?php
    function my_theme_enqueue_styles() {
    
    	$parent_style = 'parent-style';
    
    	wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    	wp_enqueue_style( 'child-style',
    		get_stylesheet_directory_uri() . '/style.css',
    		array( $parent_style )
    	);
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    ?>

    To this:

    <?php
    function my_theme_enqueue_styles() {
    	wp_enqueue_style( 'child-style',
    		get_stylesheet_directory_uri() . '/style.css',
    		array( $parent_style )
    	);
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    ?>

    ?

    Moderator Kathryn Presner

    (@zoonini)

    Glad you sorted out the menu.

    For the duplicate child-theme stylesheet, your enqueuing function looks OK to me. I would suggest leaving off the final closing PHP tag since that’s a best practice for the functions.php file ?> – but that wouldn’t be causing the duplication.

    Could you double-check your plugins and make sure you’re not also running a child-theme plugin? That could account for the double-enqueuing.

    Thread Starter cooljosh3k

    (@cooljosh3k)

    I don’t have any child theme plugins running. I only used the guide at http://codex.wordpress.org/Child_Themes that you showed me.

    Why should the closing php tag be omitted? This seems really odd to me.

    Moderator Kathryn Presner

    (@zoonini)

    Why should the closing php tag be omitted? This seems really odd to me.

    PHP.net — the PHP manual — has a good explanation here:

    If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.

    http://php.net/manual/en/language.basic-syntax.phptags.php

    And some WordPress-specific reasons here:
    http://hardcorewp.com/2013/always-omit-closing-php-tags-in-wordpress-plugins/

    I’m still not sure why your child-theme stylesheet is being enqueued twice.

    If you paste the contents of your child theme’s functions file in a Pastebin and link to it here, I’d be glad to take a look. Choose PHP syntax highlighting from the options.

    Thread Starter cooljosh3k

    (@cooljosh3k)

    My child’s function file is only small:

    <?php
    function my_theme_enqueue_styles() {
    
    	$parent_style = 'parent-style';
    
    	wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    	wp_enqueue_style( 'child-style',
    		get_stylesheet_directory_uri() . '/style.css',
    		array( $parent_style )
    	);
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    Moderator Kathryn Presner

    (@zoonini)

    I tested your function on my Bouquet test site and indeed it caused the stylesheet to be enqueued twice.

    Give this function a try instead:

    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    Thread Starter cooljosh3k

    (@cooljosh3k)

    Okay, I have now updated the child functions to exactly that.

    Moderator Kathryn Presner

    (@zoonini)

    Great, glad that did the trick. Your child theme stylesheet is no longer double enqueued.

    If you neeed help with anything else, feel free to start a new thread.

    Thread Starter cooljosh3k

    (@cooljosh3k)

    Thank you so much for all of your help.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Fixing messed up menu?’ is closed to new replies.