简体   繁体   中英

How to adjust the width of the Facebook comments plugin?

Basically, most of my page is contained in a centered table. Underneath that, I'd like to have a Facebook comments section, but I'd like it to be of the same width as the table itself (table with is 95%). As you know, the Facebook comments plugin takes a fixed width, in pixels, how do I avoid that (or overwrite it)?

Use something like jQuery to programmatically insert the comments plugin into your DOM after the page has been rendered setting it's width to the width the browser has displayed the parent div. Then call FB.XFBML.parse() to get it to show.

function adjustWidth(obj) {
    var width = parseInt($(obj).width());
    $(obj).html('<fb:like href="blah" width="' + width  + '></fb:like>');
    FB.FBXML.parse(obj);     
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM