Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

I have a question about using multiple declarations with one @media query.

Below I have added a number of background properties that I would like to change depending on the browser window width. My question is it okay to make multiple declarations in a @media query like this? Thanks in advance for any feeback.

/**********************
Responsive css file
***********************/


/***********************************
Below the background will change to
a different color when the browser
window is 480px
************************************/

@media screen and (min-width: 480px) {
  body {
    background: #00CC99;
  }

  header {
    background: #99FFCC;
  }

  .nav {
    background: #9999CC;
  }

  .main-content {
    background: #CC99FF;
  }

  footer {
    background: #99FFCC;
  }

}


/***********************************
Below the background will change to
a different color when the browser
window is 660px
************************************/

@media screen and (min-width: 660px) {
  body {
    background: #009999;
  }

  header {
    background: #CCFFCC;
  }

  .nav {
    background: #99CCCC;
  }

  .main-content {
    background: #CCCCCC;
  }

  footer {
    background: #CCFFCC;
  }

}

1 Answer

That's just fine.

What up Kev! Thanks for the reply buddy. I think I'm going to have to pay you soon for being my tutor :D Thanks again for the reply, I really appreciate it.

Lol I like that idea! Not a problem X. I learn a lot myself trying to help.