Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Need help with media queries

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #240301
    d4everman
    Participant

    Hello. I’m new here and new to css. For a class project I’m trying to resize a website to 550 px. I have only been able to get the background color to change so far. Any advice would be highly appreciated. I can’t seem to wrap my head around media queries. I’ve posted it on code pen, here is the link. http://codepen.io/d4everman/pen/qZpdNM

    #240303
    Paulie_D
    Member

    OK…but what is your actual question?

    If it’s the resizing of elements, you need to change the widths to different px values….probably change some font sizes, perhaps re-arrange the elements.

    Also, absolute positioning is a very poor way of laying out webpages..you have much better options. See – http://learnlayout.com/

    Also, you have the <header> before the <body>, you’ll need to fix that.

    #240305
    d4everman
    Participant

    Thanks. I just needed common sense advice like that, I guess. I’ll see what I can do later on today. I appreciate your time in replying.

    #240307
    bearhead
    Participant

    The only reason only the body’s background color is changing is that background-color is the only style you’re modifying within the media query:

    @media only screen and (max-width: 550px) {
    body {
    background-color: lightblue;
    }
    }

    if you wanted the body’s font size to change too, you would have to put a new rule into the media query, something like:

    @media only screen and (max-width: 550px) {
    body {
    background-color: lightblue;
    font-size:20px;
    }
    }

    You can imagine media queries as “if” statements… so for the query you wrote, you can read it as “if the screen size is 550px or less, then apply the following styles”

    Also, you might want to check your code for syntax errors… I noticed at least one rogue bracket…

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.