Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #293694

    Hi,

    I have this in functions.phpand I know it open the banner
    if( empty($_COOKIE[$cookieName])) $extraClass = "maximized ";

    What I wish, is a way to tell that when on a mobile, the class is minimized. I know it will probably be with a media query but here in PHP, I don’t know how to do.
    Thanks for your help.

    Alex

    #293852

    Hi Alex!

    Please try adding following code right below it

    if (wp_is_mobile()) $extraClass = "minimized";

    Regards,
    Yigit

    #294035

    Hi YigIt,

    Thanks for your help. It works great on a mobile but not on a tiny window on a desktop browser.
    It will do the thing but did you know a way to add a condition like a media query :
    If the width is less than that so do something (had class minimized) ?

    Best regards,

    Alex

    #294036

    Hey!

    You can try adding following code to Functions.php file in Appearance > Editor

    function add_custom_script(){
    ?>
    <script>
    jQuery(window).load(function(){
      if (jQuery(window).width() <= 768){	
    	   jQuery("div#info_text_header").addClass("minimized");
               jQuery("div#info_text_header").removeClass("maximized");
      }
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script');

    Cheers!
    Yigit

    #295695

    Thanks Yigit
    That’s great and using JQuery seems the best for this.
    And I can tweak this way more than with the dumb wp_is_mobile.
    Problem solved.
    Regards,
    Alex

    #295717

    Hi!

    Great! You are welcome Alex, glad we could help! Let us know if you have any other questions or issues :)

    Regards,
    Yigit

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Top Banner minimized when on mobile’ is closed to new replies.