18

I'm trying to apply media queries in a site but my knownledge is not deep in this topic, so basically I want to apply a specific style to a tag when the detected screen is greater than 1024*768.

I did this

@media screen and ( device-width: 1024px ) {

}

but the I've to identify when the resolution is greater than 1024

js1568
  • 7,012
  • 2
  • 27
  • 47
m4g4bu
  • 457
  • 2
  • 7
  • 19

4 Answers4

47

Try this:

@media only screen and (min-width : 1025px) {
    .classname {
        /* styles here */
    }
}


@media only screen and (max-width : 1024px) {
    .classname {
        /* other styles here */
    }
}
Mike Brant
  • 70,514
  • 10
  • 99
  • 103
11

Use a standard media screen query. The query will trigger the style changes once the width is 1024px or greater.

@media screen and (min-width: 1024px) {
    /* Styles go here */
    #layout {
        width: 90%;
    }
}
Stieffers
  • 752
  • 3
  • 13
2
@media all and (min-width: 1024px) {
  #css {
    foo : bar;
  }
}
Ties
  • 5,726
  • 3
  • 28
  • 37
1
@media (min-width: 1024px) and (max-width: 1920px) {

html { background: red; } }

  • Could you add some explanation what your code does and how it's different from other answers – Cray Jul 04 '19 at 05:27