Anyone familiar with mobile visibility and zurbs f

2019-02-20 11:28发布

问题:

I am trying to hide a div on both a tablet device and a desktop. I am using zurbs foundation http://foundation.zurb.com/docs/layout.php to do so. However when I try to apply the classes hide-on-tablets & hide-on-desktops the second one overrides the first one somehow and the hide-on-tablets shows up on a tablet. I can create my own media queries and hide them on both but I figure I should take advantage of classes or what's the point of having all the code. You can view it on my site at http://goodmorningmoon.ca by resizing the browser. The password for the site is springy88

Thanks in advance.

foundation.css visibility

/* -------------------------------------------------- 
    :: Mobile Visibility Affordances
---------------------------------------------------*/


    .show-on-phones { display: none !important; }   
    .show-on-tablets { display: none !important; }
    .show-on-desktops { display: block !important; }

    .hide-on-phones { display: block !important; }  
    .hide-on-tablets { display: block !important; }
    .hide-on-desktops { display: none !important; }


    /* Modernizr-enabled tablet targeting */
    @media only screen and (max-width: 1280px) and (min-width: 768px) {
        .touch .hide-on-phones { display: block !important; }
        .touch .hide-on-tablets { display: none !important; }
        .touch .hide-on-desktops { display: block !important; }


        .touch .show-on-phones { display: none !important; }
        .touch .show-on-tablets { display: block !important; }
        .touch .show-on-desktops { display: none !important; }

    }


    @media only screen and (max-width: 767px) {
        .hide-on-phones { display: none !important; }
        .hide-on-tablets { display: block !important; }
        .hide-on-desktops { display: block !important; }

        .show-on-phones { display: block !important; }
        .show-on-tablets { display: none !important; }
        .show-on-desktops { display: none !important; }

    }

MY HTML

<div class="row touch">
            <div id="iphoneNav" class="four columns hide-on-tablets hide-on-desktops">
                <?php wp_nav_menu( array( 'theme_location' => 'iphone-menu','menu_class' => 'nav-bar', 'container' => 'nav') ); ?>
                </div>
        </div>

回答1:

You really need to check out this then.

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

You can define different types of Style Sheets for Different Types of Devices your Website is being viewed on.

Hope that helps! Aaron



回答2:

Take a look at version 3 of Foundation: http://foundation.zurb.com/docs/media-queries.php & example in: http://foundation.zurb.com/mobile-example3.php

Use .show-for-small

If you need it for smaller device than 767px, roll your own mediaquery.

Cheers



回答3:

I think you only need one of them: https://groups.google.com/forum/?fromgroups=#!topic/foundation-framework-/Whs4dZaS31U

I hope it helps



回答4:

.touch gets added by Modernizr to the body element - you don't need to do anything for that. It's so we can tell, when a device is 1280x768 for example, if it's a desktop or tablet.

The trick to the .hide-on-x and .show-on-x classes is that you only ever need one. There is an implied 'only' in there, as in 'hide-only-on-tablets'. That should be the only one you need.

(Source: https://groups.google.com/forum/?fromgroups=#!topic/foundation-framework-/Whs4dZaS31U)