Search code examples
htmlcssiframerecaptcha

Recaptcha dark theme displays with extra white space on edges


I'm a new web developer, trying to add the latest Recatpcha to a website with a dark background. It displays with white space on some edges - a recent bug that is also being discussed in the Recaptcha Google group. I'm trying to develop a workaround until they fix it. Recaptcha is displayed as an iframe - so it should be configurable - but none of the properties visible in the DOM looks like "background". How do you force the iframe background to be transparent?

My code is here:

<!DOCTYPE HTML>
<head>
  <style>
  body {
      background-color: rgb(30, 30, 40);
  }
  </style>
  <script src='https://www.google.com/recaptcha/api.js?hl=en'></script>
</head>

<body>
  <div class="g-recaptcha" data-theme="dark" data-sitekey="6LcZuQwTAAAAAA-qE3415DMsfeGdeQ6WWlzm4Lqz"></div>
</body>
</html>

Thanks so much!

Josh


Solution

  • Quick fix:

    body {
          background-color: rgb(30, 30, 40);
      }
    .g-recaptcha {
        overflow:hidden;
        width:298px;
        height:74px;
    
    
    }
    iframe {
      margin:-1px 0px 0px -2px;  
    
    }
    

    Demo: http://jsfiddle.net/76rkfb2w/

    As @CookieMan sad, iframe content can't be styled, but, holder of iframe, and iframe box it self - can. So, this should work on dark background...