6
Is there any possibility to leave the facebook plugin with 100 width%?
I think his default is 550px wide.
6
Is there any possibility to leave the facebook plugin with 100 width%?
I think his default is 550px wide.
7
It seems that the Facebook method is not accepting percentages through the configuration option data-width
, because the value is being converted to pixels irrespective of the indicator of the type of value used (%, pt, px).
If nothing is defined, there is an element within the iframe
, specifically a div#feedback_xxxxxx
which receives the default width of 550 pixels so that any solution via the site via CSS is disabled.
$(function() {
var $myWrap = $('body'); // elemento wrapper dos comentários
width = $myWrap.width(); // recolhemos a largura em pixeis
$('.fb-comments').attr("data-width", width); // passamos a largura para o Facebook
});
So that we can resize when the screen changes width, and because there are width controls inside the iframe
whose own Comments Plugin uses, we can listen when the window is no longer resized to run the function that will set the new width for Facebook comments.
Therefore, we create a function that performs the various operations and one to listen if the window has stopped being resized:
// função para manipular a largura do PlugIn de comentários do Facebook
function fluidComments() {
var $myWrap = $('body'); // elemento wrapper dos comentários
width = $myWrap.width(); // recolhemos a largura em pixeis
// passamos a largura para o Facebook
$('.fb-comments').attr("data-width", width);
/* se existe a iFrame é porque não é o primeiro carregamento
* e também precisas de a actualizar
*/
if ($(".fb-comments > span > iframe").size()==1)
FB.XFBML.parse(); // indicação ao código do Facebook para se actualizar
}
// Correr quando o DOM está pronto
$(function() {
fluidComments();
});
/* Monitorizar o progresso do "resize" para saber se acabou
* e assim chamar a função que manipula a largura
*/
var progresso;
window.onresize = function(){
clearTimeout(progresso);
progresso = setTimeout(fluidComments, 100);
};
If by Comment Plugin you are referring to Comments (English), you can set its width using a date attribute:
data-width
The width (in pixels) of the plugin. The mobile version of the Comments plugin ignores the width Parameter, and Instead has a Fluid width of 100%.
That translated:
data-width
The width (in pixels) of the plugin. The mobile version of the Comments plug-in ignores the width parameter, and instead has a fluid width of 100%.
<div class="fb-comments"
data-href="http://example.com/comments"
data-width="100%"
data-numposts="5"
data-colorscheme="light"></div>
3
According to this response from the SOEN, it is possible yes:
Use the CSS:
.fb-comments, .fb-comments iframe[style] {width: 100% !important;}
EDIT: By the way this is a bug from facebook, recently introduced... but apparently, there is a way around the problem, as shown by the answers in SOEN:
I’ve seen it before, it didn’t work :(
I added more information... then I will transcribe the answers of SOEN, in Portuguese, of course! = D
1
With css could use the classes:
.fb-comments, .fb-comments span[style], .fb-comments iframe[style] {
width: 100% !important;
}
Browser other questions tagged jquery html css facebook
You are not signed in. Login or sign up in order to post.
I put it that way, but he got 100px and not 100%
– Jefferson Alison
You can put this inside a resize() ?
– Jefferson Alison
@Jeffersonalison Yes, please read the "Resize when the screen changes width" section in my reply.
– Zuul
That’s right @Zull, it worked.. It’s normal when resizing the browser to look as if it had been loading?
– Jefferson Alison
@Jeffersonalison It is normal yes, effectively we have to tell the Facebook code to update the Plugin, and what you refer to is the Plugin to auto-update. When the width bug is solved on their part, this is no longer necessary workaround.
– Zuul
Got it @Zuul, thanks so much for your help!
– Jefferson Alison