Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP Hiding a navigation bar.

gjellis1109

New Coder
I am needing help with putting in the code to hide a navigation bar whenever the screen resolution is less that 800px. Not sure how to do this at all considering I haven't ever really coded. Below is the code for the nav bar. Just need to know where and what to put to hide it.

[CODE title="Navigation Bar"] <!-- Menu Start -->

<nav id="header-menu">

<div id="header-menu-inner">

<?php
wp_nav_menu( array(
'theme_location' => 'header',
'menu_id' => 'header-menu-links',
'menu_class' => 'sf-menu',
'container' => false, // don't wrap in div
'fallback_cb' => false // don't show pages if no menu found - show nothing
) );
?>

<?php risen_icons( 'header' ); ?>

<div class="clear"></div>

</div>

<div id="header-menu-bottom"></div>

</nav>

<!-- Menu End -->[/CODE]
 
Hello gjellis1109!

You can do that with CSS. The following will apply the styles only if the screen height is of at least 800px:
CSS:
/* By default, the <nav> is not displayed */
nav{
    display: none;
}
@media only screen and (min-height: 800px)
{
    /* If the height of the screen is at least 800px,
       we display the <nav> */
    nav{
        display: block;
    }
}

p.s. When you include code, select which language it is ;).
 
Last edited:
Back
Top Bottom