“Hell-o”.
Here’s a simple and useful Jquery each function that takes the width of something and makes it’s height out of it. It also re-runs when the browser window is resized. I use it alot, it’s dead handy. You’re basically getting the width and making the height out of it.
See js snippet below. Give it a whirl:
//start doc ready
$( document ).ready(function() {
//make somethign square
var makesquare = function(){
$('.makesquare').each(
function(){
var thisso = $(this);
var thiswidth = thisso.outerWidth();
thisso.css('height', thiswidth);
}
);
};
//callthe function
makesquare();
//fire functions on resize
$(window).resize(function () {
makesquare();
});
//end doc ready
});
Need rapid website development:
For smaller projects at high speed
-
Adding script tag embed to Gatsby component
Read More -
Get more than 100 queries in GraphQL (I felt stupid)
Read More -
Animate on Scroll (AOS) into Nuxt js
Read More -
WordPress Super-admin hack
Read More -
Add content or ACF field under thumbnail/image gallery in Woocommerce
Read More