0

How to override css media query !important property using jquery. matchMedia not working issue

#div{
  padding-left:10px;
}
@media screen and (min-width: 767px) {
  #div{
    padding-left:15px !important;
  }
}

var minql = window.matchMedia("(max-width:475px) and (min-width:320px)");
if (minql.matches) {
  $("#div").css({"padding-left": "30px" });
}
3

1 Answer 1

0

Try this

if (window.matchMedia("(min-width: 400px)").matches) {
  /* the viewport is at least 400 pixels wide */
} else {
/* the viewport is less than 400 pixels wide */
}

You can also refer to this example: Source

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.