Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make facebook comment box width 100%?

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>

but i cannot make the comment box fill 100% of the page.

like image 200
medo ampir Avatar asked Jun 02 '12 12:06

medo ampir


3 Answers

You can do this by adding CSS class in style sheet of your HTML page as:

.fb-comments, .fb-comments span, .fb-comments iframe { width: 100% !important; }
like image 194
zeeshan ansari Avatar answered Nov 12 '22 17:11

zeeshan ansari


zeeshan your solution seems outdated and it looks like facebook updated their plugin and that broke the style.

Probably this works better for me as of now and I believe that this style will again broke when facebook update the way their plugins work.

.fb_iframe_widget,
.fb_iframe_widget span,
.fb_iframe_widget iframe[style]  {width: 100% !important;}

I encourage other contributors to add the more recent solution to this question when time comes.

like image 9
EKY Avatar answered Nov 12 '22 16:11

EKY


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()});});

so now on window resize the whole comment box is taking the container width (by other means it is 100% width).

like image 3
medo ampir Avatar answered Nov 12 '22 15:11

medo ampir