Skip to content

Instantly share code, notes, and snippets.

@marciofmjr
Last active May 9, 2018 20:07
Show Gist options
  • Save marciofmjr/ea40513d5f70f9732d408cda0394d97a to your computer and use it in GitHub Desktop.
Save marciofmjr/ea40513d5f70f9732d408cda0394d97a to your computer and use it in GitHub Desktop.
Javascript function to verify if breakpoint is mobile or not based on css
function isMobile(){
var content = window.getComputedStyle(document.querySelector('body'), ':before').getPropertyValue('content');
if(content == "\"mobile\"" || content == "mobile"){
return true;
}else{
return false;
}
}
+bp-mobile // or mobile breakpoint
body:before
display: block
width: 1px
height: 1px
overflow: hidden
opacity: 0
color: transparent
position: absolute
content: "mobile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment