How to make facebook comment box width 100%?

前端 未结 9 548
逝去的感伤
逝去的感伤 2021-01-18 00:27

i am using this code to put a facebook comment box to my page,



        
相关标签:
9条回答
  • 2021-01-18 01:01

    With jQuery you can over-write the hard-coded width before it loads the Facebook comment box.

    $('document').ready(function(){
        $('.fb-comments').attr('data-width',$('body').width());
    });
    

    p.s. you can replace 'body' with any other element you want the comment box to match.

    0 讨论(0)
  • 2021-01-18 01:03

    This is fairly simple On your code

    Add the following piece of code data-width="100%"

    <div class="fb-comments" data-href="{{ post.build_absolute_uri }}"data-width="100%" data-numposts="5"></div>

    0 讨论(0)
  • 2021-01-18 01:07

    Try adding the parameter data-width="{pixels}", as you’re getting when you get the code created on this page, https://developers.facebook.com/docs/reference/plugins/comments/ – that is, if you know the width of the page in pixels. I don’t know, if it works with percentages as well, but somehow doubt it.

    Then your last option might be to add resp. modify that parameter dynamically once your page has loaded and you can read out the actuall width in pixels, and have XFBML only parsed afterwards (setting xfbml param to false while loading the script, and calling FB.XFBML.parse after setting the data-width parameter). Of course, that still won’t help you, if the width get’s modified later by the user resizing the browser window or else …

    0 讨论(0)
提交回复
热议问题