How can I make the Facebook Like button's width automatically resize?

后端 未结 8 1113
清酒与你
清酒与你 2020-12-13 13:53

I\'m implementing the Facebook Like Button, but I\'m running into some trouble with the width. I\'m using the JavaScript SDK implementation, not the direct iframe.

A

8条回答
  •  青春惊慌失措
    2020-12-13 14:40

    If you use the XFBML version of the Like button, along with the Facebook Javascript SDK, you can subscribe to the 'xfbml.render' event, and once that event fires, you can set the width of the like button iframe to some small value. (I use 50px.) The iframe will then auto-adjust its width as needed in order to display button and like count and whatever other elements, according to your config.

    https://developers.facebook.com/docs/reference/javascript/

    The biggest obstacle to this solution is that you will need a Facebook App ID. You can get an App ID by creating an app here: https://developers.facebook.com/apps/

提交回复
热议问题