Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove class with media queries

When @media screen and (max-width: 500px) is in active removing class .fade . How can i do this? my script is here below.

@media screen and (max-width: 500px) {
    .post_profile_image{
        width:35px;
        height:35px
    }
    .fade{
    /* Remove this class */
    }
}

<div id="myModal" class="modal fade" role="dialog">
like image 226
ÄR Âmmãř Żąîñh Avatar asked Sep 06 '15 08:09

ÄR Âmmãř Żąîñh


People also ask

Can @media queries add or remove classes to elements?

Media queries can't add or remove classes to elements, they merely change what rules apply to elements. @ÄRÂmmãřŻąîñh: That's a different question (and one I don't happen to know the answer to). can i remove class with javascript when When @media screen and (max-width: 500px) is in active .?? or other sollutions??

How do I override all properties in a media query?

If you want to override ALL properties, use the “all: initial;” property, followed by whatever properties you wish to add. Why aren't my media queries working? Because other css rules applies on that same object that are written later in the css file or because your browser/mobile width in px not wide enough to the media querie to be applied.

Can I use CSS media queries to manipulate the Dom?

Css media queries do nothing to manipulate the DOM. That kind of functionality falls under the Javascript domain. However, even if possible, that might not be the best way to go about it, since Media queries do not make a distinction based on device, but rather on browser width.

What can I do with a media query?

A common use of media queries, is to create a flexible layout. In this example, we create a layout that varies between four, two and full-width columns, depending on different screen sizes: Tip: A more modern way of creating column layouts, is to use CSS Flexbox (see example below).


2 Answers

How to remove class with media queries

You don't. Instead, you define new rules that apply to the class which do the styling you want done. Media queries can't add or remove classes to elements, they merely change what rules apply to elements.

like image 196
T.J. Crowder Avatar answered Sep 20 '22 15:09

T.J. Crowder


$(window).resize(function(){
 If($(window).width()<500){
  $('.fade').removeClass('fade');
 }
});
like image 23
Ahmadbaba46 Avatar answered Sep 21 '22 15:09

Ahmadbaba46