Some day ago a client wanted to add Google noCAPTCHA reCAPTCHA to the gravity form. all looks fine but when i was visiting the site on mobile devices the Google reCAPTCHA overlapping the screen.
Its not looking good some how i need to fix it and resize the Google reCAPTCHA. There are not enough resources to control the Google noCAPTCHA reCAPTCHA, but it seemed no matter what I tried to target with CSS or a combination of CSS and javascript, nothing seemed to change the look of the captcha. So rather than trying to change what was generated by Google’s externally-loaded javascript and css files, I decided to change what I felt I could change – the div you place on your site with the g-recaptcha class that loads up the reCAPTCHA.
Then i was tried several css code but no one working. then i was thing about the transform:scale(value) and transform-origin: (value) . By using the CSS transform property you can achieve changing the width by changing the entire scale of the reCAPTCHA.
By adding in just two inline styles, you can make the reCAPTCHA fit nicely on your mobile device:
Much nicer!
How and where you need to add the css, simple inspect your browser by pressing ctrl+shift+I (For windows) or right click on mouse and click on Inspect and then find the class=”some-class” data-theme=”light/dark” data-sitekey=”XXXXXXXXXXXXX” just copy the class or id and use the css
transform:scale(0.77); -webkit-transform:scale(0.77); transform-origin:0 0; -webkit-transform-origin:0 0;
the -webkit- code for browser supporting code. you should adjust the transform:scale(0.77); to any point. Make sure you will keep same point to -webkit-transform:scale(0.77); here also. and keep as it the transform-origin:0 0; -webkit-transform-origin:0 0;
So, in order to have the reCAPTCHA align to the top left, I set it so the transformation would originate from the top left-hand corner (rather than from the center, which is the default). I used “0 0”, but “left top” would have had the same effect.
That’s just a basic way to show how you can quickly change the size of the reCAPTCHA with inline styling. For something nicer, I’d suggest assigning a new class and leaving it at full size for anything above mobile, then using a media query to change it to the smaller size. Even better would be to use a transition effect so it visually “shrinks down” when you go to mobile.
To scale the images popup, you can use this code, either by inserting it as a separate style embed (like below) or simply adding it to your CSS:
<style> .g-recaptcha { transform:scale(0.77); -webkit-transform:scal(0.77); transform-origin:0 0; -webkit-transform-origin:0 0; } </style>
Media queries:
<style> @media screen and (max-width: 575px){ .g-recaptcha { transform:scale(0.77); -webkit-transform:scale(0.77); transform-origin:0 0; -webkit-transform-origin:0 0; } } </style>
If you found this useful, please let me know in the comments below.
Thank you MD. Elias. You save my day!
Sound Good… 🙂
i copied this code and apply in css . it was changed on reduce the scale value, after refresh the browser it will come default captcha size
Hello Perumal,
I think the css is not updated due to Cache. better you can add the css here
Appearance -> Customize -> Additional CSS http://prntscr.com/lruztd
here http://prntscr.com/lrv13q
and Publish the changes.
let me know if its not work..
Thanks
I had this issue and I added the class g-recaptcha to the CAPTCHA item in the form edit screen and it works perfectly. This is mentioned here but not called out. You can miss it if you read this too fast like I did 🙂 this 100% works and the @media are very good as is the scale ratio, I bet it took a while to figure out.
Thank you man. you save my time. i appreciate your work. carry on man.
Sound Good 🙂
Better way is use data-size=”compact” parameter for .g-recaptcha element
Thanks for your comment. yes, it will work…
Ty sir, this is a lifesaver. Nice site.
Thanks for your Comment