I'm developing a site around the "responsive design" concept, but the facebook social plugins are static width and "break" the layout when it's re-sized.
Using media queries, I've set the plugins to hide on low-res browsers (mobile, etc...). However, on desktop browsers, when the browser window is re-sized smaller, but not so small to hide the plugins, they break out of the layout.
Any way to set a fluid width for the Facebook social plugins?
The correct working answer is a combination of things I found here. Mikel's answer is a good start:
Facebook Developers Platform link
This says:
But... This will load the width of what's available to the plugin at loading time. When you resize your page it will remain the same width it had when you loaded the page. To fix this - and make a true responsive version of the Facebook Social Plugin - Add the following in your CSS:
This will cause the plugin to resize to the available space as you resize the window.
If you want this code to work for the page plugin, change the class-name 'fb-comments' to 'fb-page':
(thanks for the addition Black_Stormy!)
I think
max-width
is better thanwidth
in this case, and it works for me:This works for me:
I managed to make it work by using this code:
because in my html file I have this:
Tip: You should change your css depending of the div class.
This works for me
Here's a complete example, using jQuery, with a response width and a loading image. The CSS code of Alan and Jubair is commented in the code.
That's works fine in an Android webview