The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "SVG" Oct 14 - 6:30 PM Eastern
Get a free trial // Grow your CSS skills // Land your dream job

Media Queries

  • # June 10, 2011 at 11:06 am

    On this site:

    I’m trying to add some media queries….

    They are:

    @media screen and (max-device-width: 480px) {
    /* Uncomment if you don't want iOS and WinMobile to mobile-optimize the text for you
    html { -webkit-text-size-adjust:none; -ms-text-size-adjust:none; } */
    .slidercontainer {display:none}
    #wrapper {width:320px}
    #mainMenu {top:150px;}
    #cta {width:100%;height:100%;}
    a.qbutton, a.q2button, a.servicebutton, .charterbox a {width:120px;margin-left:10px;}
    #homeBoxes {margin-top:100px;width:320px;}
    #homeBoxes .homeBox {width:280px;}
    #footercontact {width:310px;}
    #footer {width:320px}


    However, when I resize my browser window, they have no effect. Nothing changes? On other sites with media queries they work. I’m struggling to see what’s gone wrong :(

    # June 10, 2011 at 11:37 am


    in case you do not have IPHONE and testing it on screen use
    @media screen and (max-width: 480px)

    it works just fine, once web is finished you replace it with

    and you can be sure it works on phone :)

    # June 10, 2011 at 11:42 am

    + some older browsers ( IE ) … DO NOT support media queries by native behaviour

    just for info

    # June 10, 2011 at 11:46 am

    to enable MQ in old browsers go here for script and info

    # June 10, 2011 at 11:47 am

    Okay – thanks. I’ve done that now, and the slider now disappears when I shrink the browser.

    However none of my other queries are having an effect. I want the wrapper for example to shrink to a width of 300px so everything fits.

    Any ideas? Thanks :)

    # June 10, 2011 at 11:51 am

    read this for inspiration as I did

    maybe silly answer but if you need 3 different widths of your wrapper
    screen, ipad, iphone

    you need 3 different queries with proper values

    @media screen and (max-width: 980px) {
    #wrapper {width: 980px;}

    @media screen and (max-width: 500px) {
    #wrapper {width: 500px;}

    @media screen and (max-width: 200px) {
    #wrapper {width: 200px;}
    # June 10, 2011 at 11:52 am

    I’m doing the exact same as them, so far as I can see. Have even tried using their % width method. But nothing resizes :(

    # June 10, 2011 at 11:57 am

    % = for really “liquid” design
    px = well it “triggers the layout” once it reaches proper width of browser portview

    # August 9, 2011 at 5:12 pm

    You also need to make sure that you’ve declared a Meta viewport tag. See slide 36 of this presentation to learn more:

    But I was having trouble with mobile and tablet not recognizing the MQs, but as soon as I added the Meta tag, it all cleared up nicely.

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

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed