Skip to content

Instantly share code, notes, and snippets.

@Irfan-Ansari
Created July 4, 2014 06:41
Show Gist options
  • Save Irfan-Ansari/72a748a11c08dd84d94c to your computer and use it in GitHub Desktop.
Save Irfan-Ansari/72a748a11c08dd84d94c to your computer and use it in GitHub Desktop.
Squarifying Bootstrap Spans
Squarifying Bootstrap Spans
I just wrote a quick little js plugin to make any element's height equal to it's width. It's not really bootstrap specific, but it's helpful for spans if you need a span to be square at all times, even when the responsive resizing is done.
Introducing Squarify...
function squarifyMe(element) {
squareItUp()
window.onresize = function(element) {
squareItUp();
}
function squareItUp() {
$(element).height($(element).width());
}
}
Which minifies into...
function squarifyMe(b){a();window.onresize=function(c){a()};function a(){$(b).height($(b).width())}};
Call it on an element!
To make use of the squarify plugin, just apply it to an element on page load:
$(document).ready(function() {
squarifyMe('.myElement');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment