Skip to content

Instantly share code, notes, and snippets.

@mahbubur001
Created November 13, 2019 04:42
Show Gist options
  • Save mahbubur001/8ec5ea065bb1fcb0e14dbed1a1e8177b to your computer and use it in GitHub Desktop.
Save mahbubur001/8ec5ea065bb1fcb0e14dbed1a1e8177b to your computer and use it in GitHub Desktop.
reCAPTCHA Responsive Scaling
(function ($) {
function scaleCaptcha() {
$('.ginput_container.ginput_recaptcha').each(function () {
var self = $(this),
width = $(this).parent().width();
if (width < 302) {
var scale = width / 302;
self.css('transform', 'scale(' + scale + ')');
self.css('-webkit-transform', 'scale(' + scale + ')');
self.css('transform-origin', '0 0');
self.css('-webkit-transform-origin', '0 0');
}
});
}
// Initialize scaling
scaleCaptcha();
// Update scaling on window resize
// Uses jQuery throttle plugin to limit strain on the browser
$(window).resize($.throttle(100, scaleCaptcha));
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment