Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centering No Captcha reCaptcha

After a few hours of research and trial and error, I was finally able to add the new Google No Capatcha re Capatcha to my form and get it working, but for some reason, it won't center. Any ideas?

<!-- reCapatcha -->
<div id="capatcha">
    <div class="g-recaptcha" data-sitekey=""></div>
</div>


#capatcha {
    margin: 0 auto;
    display: block
}
like image 577
Jacko Avatar asked Dec 10 '14 21:12

Jacko


People also ask

What is no Captcha reCAPTCHA?

We're calling it the "No CAPTCHA reCAPTCHA" and this is how it looks: On websites using this new API, a significant number of users will be able to securely and easily verify they're human without actually having to solve a CAPTCHA. Instead, with just a single click, they'll confirm they are not a robot.

How do I resize a reCAPTCHA?

The easiest way of resizing Google recapture is by adding inline style. Inline styles are the CSS styles that applied directly to the HTML element by using the style attribute.


2 Answers

I went with:

<style>
    /* already defined in bootstrap4 */
    .text-xs-center {
        text-align: center;
    }

    .g-recaptcha {
        display: inline-block;
    }
</style>
<div class="text-xs-center">
    <div class="g-recaptcha" data-sitekey=""></div>
</div>
like image 129
jxmallett Avatar answered Oct 14 '22 01:10

jxmallett


This is similar to other answers, but I thought worth sharing. I don't like hard-coding values, but the width of the No Captcha reCAPTCHA appears to be 304px, so you could use that as your width:

<style>
div.g-recaptcha {
  margin: 0 auto;
  width: 304px;
}
</style>

<!-- reCAPTCHA -->
<div class="g-recaptcha" data-sitekey=""></div>

This should center the reCAPTCHA exactly.

like image 40
russianmario Avatar answered Oct 14 '22 02:10

russianmario