Created
July 4, 2014 06:41
-
-
Save Irfan-Ansari/72a748a11c08dd84d94c to your computer and use it in GitHub Desktop.
Squarifying Bootstrap Spans
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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