facebook share HTML5 TypeError: getComputedStyle(…) is null

自作多情 提交于 2019-12-10 03:49:22

问题


I'm trying to add facebook share to a page. My issue is with multiple share buttons, first works well but others aren't shown in the page. A note, first share button is visible but others are in a container with display:none css applied.

I have this code in top of the page (I changed facebook app Id to FacebookAppID):

<div id="fb-root"></div>
<script>(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/es_ES/all.js#xfbml=1&appId=FacebookAppID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

It is each share div in the page:

<div class="fb-share-button" data-href="@url" data-type="button_count" data-width="450"></div>

This issue can be reproduced in IE.

Thanks


回答1:


The display:none is what is causing the problem

You will need to hide it using opacity, height, and overflow

.fb-share-button { opacity: 0; height: 0px; overflow: hidden; }

and to show it (height can obviously be changed to whatever you like

.showfb.fb-share-button { opacity: 1.0; height: 21px; overflow: visible; }


来源:https://stackoverflow.com/questions/22484768/facebook-share-html5-typeerror-getcomputedstyle-is-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!