Skip to content

Instantly share code, notes, and snippets.

@marciofmjr
Created May 4, 2018 01:32
Show Gist options
  • Save marciofmjr/7d76ed659cceb331acc52e5ad055135f to your computer and use it in GitHub Desktop.
Save marciofmjr/7d76ed659cceb331acc52e5ad055135f to your computer and use it in GitHub Desktop.
Javascript function that helps to develop responsive, easily showing changes between breakpoints
$(document).ready(function() {
responsiveHelper([
{size: 1199, label: "xlarge"},
{size: 1049, label: "Large"},
{size: 799, label: "medium"},
{size: 576, label: "small"}
]);
});
function responsiveHelper(e){var r=["red","blue","green","pink","purple","yellow"];jQuery("body").append('<div id="responsivehelper"></div>'),jQuery("body").append("<style>.responsivehelper-bar{display:none;}</style>"),jQuery.each(e,function(e,p){var i=p.size,n=p.label;jQuery("body").append("<style>@media screen and (max-width: "+i+"px){.responsivehelper-bar."+n.toLowerCase()+"{display:block;}}</style>"),jQuery("#responsivehelper").append('<div class="responsivehelper-bar '+n.toLowerCase()+'" style="position:fixed; bottom:0; left: 0; width: 100%; height: 30px; line-height:30px; text-align:center; color: #fff; font-size: 30px; background: '+r[e]+"; z-index: "+(999+e)+'; ">'+n+"</div>")})}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment