0

I've started using Sass in my projects and I've come across a peculiar problem that I never faced using vanilla CSS.

For some reason my media queries will never get rendered (even when placed at the bottom of the file and the criteria is met); the browser will always render the original properties and their values unless I use !important (which I don't want to do because it's bad practice and just unnecessary).

I've tried putting the media queries at the top of the file and still nothing.

This is my code:

#content .result{
    display: inline-block;
    width: 725px;
    border-right: $border;
    vertical-align: top;
}

// this will be shown in Chrome developer tools when the viewport reaches 1120 pixels or less, 
// but all the new properties will be crossed out and the browser will decide to use the old
// values instead - i have no idea why
@media screen and (max-width: 1120px){
    .result{
        // will all be crossed out
        display: block;
        width: auto;
        border-right: none;
    }
}

Now I don't know if I've missed something completely obvious (unlikely, I've used media queries hundreds of times), or this is just a quirk of Sass, but any help is greatly appreciated. Cheers.

EDIT: As you can see, I have no other styles defined. And, the media query is in fact almost 200 lines after the original property declarations.

Image

GROVER.
  • 4,071
  • 2
  • 19
  • 66

1 Answers1

1

You have a more specific rule #content .search-results that wins over .search-results.

Either you remove the #content selector from the first rule or you add it inside the mediaquery so both the selectors can have the same specificity.

Fabrizio Calderan
  • 120,726
  • 26
  • 164
  • 177