html - jQuery function prevents media queries to trigger -



html - jQuery function prevents media queries to trigger -

i have few media queries in css alter properties of html elements. 1 of element div called .downloads , 1 of properties changing height of .downloads.

@media (max-width: 764px) { .downloads { height: 500px; } }

i have jquery function manipulates height of .downloads on action user does.

$('.downloads').animate({'height': 250}, 500);

problem is, after jquery function, media queries not work anymore. assume is, because height got placed inline after jquery function got triggered.

<div class="downloads" style="height: 250px;"></div>

is there thought problem? thanks

ok, think you're trying do...

you want animate element , down, remain fixed in 500px when on smaller screen. so, should not using jquery, add together inline styling element, , you'll not able command mix media queries rules...

instead, add/remove class have height animation, , toggle jquery. then, can disable class properties on media query rule:

something this

css:

.downloads { height: 0px; transition: 0.5s; overflow: hidden; border: 1px solid red; } .downloads.change { height: 250px; } @media (max-width: 764px) { .downloads, .downloads.change { transition: none; height: 500px; } }

js:

$('button').on('click', function() { $('.downloads').toggleclass('change'); });

jquery html css media-queries

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -