Skip to content

Instantly share code, notes, and snippets.

@dospuntocero
Created November 1, 2017 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dospuntocero/4100afe307facb845a8191a391a7d00f to your computer and use it in GitHub Desktop.
Save dospuntocero/4100afe307facb845a8191a391a7d00f to your computer and use it in GitHub Desktop.
use jquery to test for changed css property and make responsive changes. instead of checking on browser width
//The CSS
.tocheck {float:left;}
@media only screen and (max-width: 800px){
.tocheck {float:none;}
}
//The jQuery
$(document).ready(function() {
// run test on initial page load
checkSize();
// run test on resize of the window
$(window).resize(checkSize);
});
//Function to the css rule
function checkSize(){
if ($(".tocheck").css("float") == "none" ){
// your code here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment