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

Gregory Golinski
Gregory Golinski
5,783 Points

Media query doesn't work

Hi,

I typed a media query in my project but when I test it, it doesn't work at all. I added the viewport code in my html file, and here is the CSS code (media query at the end):

body {
    background-color: #fff;
    font-family: 'Roboto', sans-serif;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center;
}

header, footer {
    margin: 0 !important;
    padding: 5px !important;
    background-color: #fafafa;
    text-align: center;
}

h1 {
    text-align: center;
    padding-top: 4%;
}

nav {
    text-align: center;
}

nav a {
    display: block;
    text-decoration: none;
    background-color: #fff;
    padding: 10px 0;
    margin: 9px 14px;
}

p {
    color: darkgray;
    width: 80%;
    margin: 30px auto;
}

#main {
    background-color: #fff;
    text-align: center;
    padding-top: 25px;
}

#main a {
    text-decoration: none;
}

#profilepic {
    width: 300px;
    margin-top: 20px;

}

.portfolioimage {
    width: 92%;
    height: 92%;
    margin-top: 20px;
}

.title {
    color: black;
    font-weight: bold;
    font-size: 20px;
}

#title2 {
    padding-top: 30px;
    color: black;
    font-weight: bold;
    font-size: 20px;
}

#bottomtext {
    border-top: 1px solid black;
    width: 90%;
    margin: 0 auto;
}

#studentname {
    float: left;
    padding: 30px 0;
}

#back {
    float: right;
    padding: 30px 0;
}

.bold {
    color: black;
    font-weight: bolder;
}

//* Media queries *//

@media only screen and (min-width: 768px) {
    nav a {
    display: inline;
    text-decoration: none;
    background-color: none;
}
}

Any idea? I don't understand why nothing happens with this media query. I'm working in the Brackets coding tool and trying to preview the media queries in Chrome. I can't see any difference when I change the Chrome browser size to preview the changes. Thanks!

1 Answer