I was using:
.fb-comments, .fb-comments span, .fb-comments iframe[style] {
width: 100% !important;
}
To make Facebook Comments responsive on my website. This was working fine and dandy just the other day. Today I look and they have changed their code. Is it possible to get this working again?
Here's a new CSS-only solution. Did this for a project I'm working on today (July 16, 2014) and it works beautifully.
<div class="fb-comments"
data-href="http://example.com/comments"
data-numposts="10"
data-width="100%"
data-colorscheme="light"></div>
.fb_iframe_widget,
.fb_iframe_widget span,
.fb_iframe_widget span iframe[style] {
min-width: 100% !important;
width: 100% !important;
}
The trick are data-width: 100%
and min-width: 100% !important; width: 100% !important;
I got bit by this too. I put in a JS hack. Basically bind to the resize event of the window and redraw the comments widget when it fires (uses jquery if you want I can post without):
$(window).resize(function(){
$(".fb-comments").attr("data-width", $(".comments").width());
FB.XFBML.parse($(".comments")[0]);
});
In the example above .comments
is the container that you want the width of the fb-comments
to expand to. The downside of this is that when the window is resized the comments widget is reinitialized.
If you use underscore wrap the resize handler using debounce
to keep it from firing to often.
This issue is now fixed by Facebook (Comments Plugin Is Now Forcing Fixed Width)
You should use data-width="100%"
See the documentation: https://developers.facebook.com/docs/plugins/comments
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With