How to make Facebook comments widget a fluid width?

后端 未结 19 1528
执念已碎
执念已碎 2020-12-13 00:46

Is it possible to make Facebook\'s comments widget a fluid width? Their documentation shows a width field for the fb:comments xfbml or iframe which is specifie

19条回答
  •  无人及你
    2020-12-13 01:30

    This is the only thing that worked correctly for me!

    $(".fb-comments").attr("data-width", $(".fb-comments").parent().width());
    $(window).on('resize', function() {
    resizeFacebookComments();
    });
    
    function resizeFacebookComments() {
    var src = $('.fb-comments iframe').attr('src').split('width='),
    width = $(".fb-comments").`enter code here`parent().width();
    
    $('.fb-comments iframe').attr('src', src[0] + 'width=' + width);
    }
    

提交回复
热议问题