google +1 button adds scroll bar to my site

这一生的挚爱 提交于 2019-12-04 08:22:01

borrowing from superware's answer, was having the same problem... however, this worked for me:

iframe[id^="oauth2relay"] { position: fixed !important; }

Google's +1 button is adding the following iframe to the end of the page body:

<iframe name="oauth2relayXXXXXXXXX" id="oauth2relayXXXXXXXXX" src="https://accounts.google.com/o/oauth2/postmessageRelay?parent=http%3A%2F%2Fwww.example.com#rpctoken=XXXXXXXXX&amp;forcesecure=1" style="width: 1px; height: 1px; position: absolute; left: -100px;"></iframe>

One workaround (to this Google bug) can be to include the following rule in your CSS:

iframe[id^="oauth2relay"] { left: auto !important; right: -100px !important; }

If your website is all RTL then it should work fine, but if it's also LTR (multilingual) you will have to somehow target that role on RTL pages only. Check resizenow.com.

The iframe is no longer used to render the information bubble. therefor, the previously suggested solution will not work anymore.

To fix the issue define the data-onendinteraction callback attribute.

<div class="g-plusone" data-onendinteraction="gplusoneinteraction"></div>

Then, implement the interaction callback function:

window.gplusoneinteraction = function(params) {
    $('iframe[id^="oauth2relay"]').next('div').css({left: 0, right: '-10000px'});
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!