如何使Facebook评论框宽度100%? [英] How to make facebook comment box width 100%?
问题描述
我使用此代码将Facebook评论框放到我的页面,
i am using this code to put a facebook comment box to my page,
<script type="text/javascript">
(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/en_US/all.js#xfbml=1&appId=397337283630353";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-comments" data-href="https://apps.facebook.com/driftee/" data-num-posts="5" data-width="470" data-colorscheme="dark" style="width: 100% !important;"></div>
但我无法使注释框填满页面的100%。
but i cannot make the comment box fill 100% of the page.
推荐答案
很好,我想我设法解决它,
i分析了注释框,并看到fb-comments div包含一个跨度宽度默认情况下是470px,并且在这个范围内我发现一个相同宽度的iframe,所以解决方案是更改span和iframe宽度在窗口resize使用jquery像这样:
well i think i managed to solve it, i analysed the comment box and saw that the fb-comments div is containing a span with the width of 470px by default, and inside this span i found an iframe of the same width, so the solution is to change the span and iframe width on window resize using jquery like this:
$(window).resize(function(){$('.fb-comments iframe,.fb-comments span:first-child').css({'width':$('#commentboxcontainer').width()});});
所以现在在窗口调整大小整个评论框是取容器宽度(换句话说它是100 %width)。
so now on window resize the whole comment box is taking the container width (by other means it is 100% width).
这篇关于如何使Facebook评论框宽度100%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!