Google Docs iFrame: How to customize the css of an embedded Google Docs iFrame

Fadi Obaji picture Fadi Obaji · Mar 22, 2016 · Viewed 11.5k times · Source

I have this code of an iframe displaying a google docs document:

<div itemprop="description" class="col-xs-12 no-h-padding" id="article_desc" style="margin:0 auto; width:90%; float:none;">

  <iframe src="https://docs.google.com/viewer?url=http://example.com/docs/1.pdf&hl=ar&embedded=true" scrolling="no"></iframe>

</div>

The iFrame works great and display the following iFrame: Screenshot

Now i want to change the grey background as seen in the picture above into a white background color, i've been searching for a solution and i come up with this, but it's not working, the background turned white (with my custom css) but google docs didn't work and it displayed a message telling me "something went wrong" inside of the iFrame.

Does anybody know how can i change the grey background color ?

EDIT It works on Google Chrome and Opera but not on Firefox nor Safari.

Answer

Jordon Birk picture Jordon Birk · Apr 2, 2016

I can't say for certain whether this is the issue or not, but, because it's appearing differently in different browsers, I'm inclined to believe it's a matter of CSS normalizing/resetting. This answer has a script for doing that, and several more are in the comments, so I recommend checking it out.