recaptcha icon indicating copy to clipboard operation
recaptcha copied to clipboard

ReCaptcha is not really responsive.

Open Chris2011 opened this issue 11 years ago • 79 comments

As I have the problem now, the recaptcha has a fixed size and should be responsive. Here is a bug ticket from februrary: https://code.google.com/p/recaptcha/issues/detail?id=215

Chris2011 avatar Aug 10 '15 19:08 Chris2011

It's too bad it isn't responsive indeed. The only decent workaround I have found so far is scaling the whole thing down a bit with css transform.

wouterds avatar Aug 10 '15 20:08 wouterds

You can also try specifying the data-size="compact" attribute. Though, this does only affect the initial display of the widget, not the potential additional UI if further verification is needed.

rowan-m avatar Aug 20 '15 12:08 rowan-m

The image select box is now broken with an annoying text area :disappointed:, hoping someone can submit a fix.

qcam avatar Aug 20 '15 14:08 qcam

@huynhquancam do you have a screenshot or a way to reproduce?

rowan-m avatar Aug 20 '15 14:08 rowan-m

@rowan-m thanks, here is the screenshot from my localhost

screen shot 2015-08-20 at 9 43 11 pm

and also the HTML generated

<div class="form-group">
  <script src="//www.google.com/recaptcha/api.js" async="" defer=""></script>
  <div class="g-recaptcha" data-sitekey="XXX">
    <div>
      <div style="width: 302px; height: 422px; position: relative;">
        <div style="width: 302px; height: 422px; position: absolute;">
          <iframe src="https://www.google.com/recaptcha/api/fallback?k=XXX&amp;hl=en&amp;v=r20150812220525&amp;t=1&amp;ff=true" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe>
        </div>
      </div>
      <div style="border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px; height: 60px; width: 300px;">
        <textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid #c1c1c1; margin: 10px 25px; padding: 0px; resize: none; "></textarea>
      </div>
    </div>
  </div>
  <noscript>&lt;div style="width: 302px; height: 352px;"&gt;  &lt;div style="width: 302px; height: 352px; position: relative;"&gt;    &lt;div style="width: 302px; height: 352px; position: absolute;"&gt;      &lt;iframe src="//www.google.com/recaptcha/api/fallback?k=XXX"                frameborder="0" scrolling="no"                style="width: 302px; height:352px; border-style: none;"&gt;        &lt;/iframe&gt;      &lt;/div&gt;      &lt;div style="width: 250px; height: 80px; position: absolute; border-style: none;              bottom: 21px; left: 25px; margin: 0px; padding: 0px; right: 25px;"&gt;        &lt;textarea id="g-recaptcha-response" name="g-recaptcha-response"                   class="g-recaptcha-response"                   style="width: 250px; height: 80px; border: 1px solid #c1c1c1;                   margin: 0px; padding: 0px; resize: none;" value=""&gt;         &lt;/textarea&gt;      &lt;/div&gt;    &lt;/div&gt;  &lt;/div&gt;</noscript>
</div>

qcam avatar Aug 20 '15 14:08 qcam

Here is a hack that worked for me:

.gc-reset{ transform:scale(0.95) !important; -webkit-transform:scale(0.95) !important; transform-origin:0 0 !important; -webkit-transform-origin:0 0 !important; }

gc-reset is a class that is used in three wrappers around the imageselect, so the transform is applied three times.

uri111 avatar Oct 21 '15 23:10 uri111

@recfish That's how I did it as well, not very beautiful but it works.

wouterds avatar Oct 22 '15 10:10 wouterds

Why is this not being fixed? A lot of websites are responsive, and a lot of traffic goes via mobile devices. It makes no sense that recaptcha is not responsive as well.

ghost avatar Mar 29 '16 10:03 ghost

I really agree with that but for me, as a workaround the scale thing was working for me.

Chris2011 avatar Mar 29 '16 11:03 Chris2011

Hopefully scaling this will work across devices but seriously.... Why isn't this fixed yet????

goldhand avatar Apr 14 '16 00:04 goldhand

+1... It's sort of unbelievable that this is not responsive. And what's with the id-less, class-less div wrapping the iframe with a set width? or is that just the rails Gem doing that??

unRARed avatar Apr 26 '16 06:04 unRARed

+1 It's really not responsive :/ , Any news?

gran33 avatar Apr 27 '16 08:04 gran33

For Bootstrap 3 (+ 480px breakpoint hack) the following code (written in SCSS) partially solved my problem:

// Extra small (<480px)
@media(max-width: $screen-xs-max){
  .g-recaptcha iframe {
    max-width: 100%;
    transform:scale(0.77);
    -webkit-transform:scale(0.77);
    transform-origin: center center;
    -webkit-transform-origin: center center;
  }
  #rc-imageselect {
    transform:scale(0.77);
    -webkit-transform:scale(0.77);
    transform-origin:0 0;
    -webkit-transform-origin:0 0;
  }
}

// Medium small (>=480px)
@media(min-width: $screen-ms-min){
  #rc-imageselect {
    transform: none;
    -webkit-transform: none;
  }

  .g-recaptcha iframe {
    max-width: none;
    transform: none;
    -webkit-transform: none;
  }
}

// Horizontally center the recaptcha - applied to all widths
.g-recaptcha > div > div{
  margin: 4px auto !important;
  text-align: center;
  width: auto !important;
  height: auto !important;
}

This code will horizontally center your recaptcha and scale it when width less than 480px. However, this code also hides part of the recaptcha when you have a device with less than ~403px wide.

There's anyone here with more css skills than I that can solve this problem?

Code based on How to resize the Google noCAPTCHA reCAPTCHA. Btw Google, please implement responsiveness support.

paladini avatar May 18 '16 13:05 paladini

Any plans or update if and when it would be made responsive? @rowan-m

wouterds avatar Jun 02 '16 08:06 wouterds

My solution is a pure JS approach. Using jquery + bootstrap 3 (img-responsive class).. though im sure it's quite easy to pull out that little bit of css related to img-responsive.

var recaptchaCallback = function () {
    $('.g-recaptcha').each(function() {
                var rc = grecaptcha.render(this, {
          'sitekey' : ..,
          'theme': ..,
          'callback': ..
                });

               $(this).find('iframe:first')
               .removeAttr('width')
               .addClass('img-responsive')
               .parent()
               .css('width', 'auto');
        });
};

jayesbe avatar Jun 19 '16 11:06 jayesbe

On small smartphones (iPhone 3, S3 mini) it's even worse: the re-captcha container gets cut off on the right. A lot of our mobile visitors still use these kind of small smartphones. It's actually quite unbelievable that Google, the creator of so many great frameworks and fierce supporter of mobile front-ends, is not capable of or willing to do a responsive re-captcha.

drakanor avatar Jul 18 '16 08:07 drakanor

Just label this: won't fix

goldhand avatar Jul 18 '16 13:07 goldhand

@goldhand because of? There should be a reason for doing a won't fix. All the solutions are workarounds for me.

Chris2011 avatar Jul 19 '16 06:07 Chris2011

@goldhand @Chris2011: There's indeed no solution yet, it should be fixed. Right now it's little hacks and workarounds. And when the test is displayed it's completely broken. I don't understand how this bug is still open after all these months.

wouterds avatar Jul 19 '16 07:07 wouterds

@Chris2011 sorry for my sarcasm. It's been almost a year since this issue's been open but that's not an excuse to be negative.

goldhand avatar Jul 19 '16 13:07 goldhand