Yup, this seems to be a long-documented problem (applying to other plugins like login) which Facebook weren't able to fix for the like button.
One fix suggested on the dev forums is a very reasonable one: set data-show-faces="false"
but does nothing for me.
Apparently
When the bug is triggered fb js fails to assign the iframe (.fb_iframe_widget_lift) a width/height. As a result the iframe has an auto width/height of 300px/1000px.
Ideally this would be an easy bug to patch around, as we could give
the iframe a min/max width/height. However, since all Like button
clicks show the post comment modal, this solution is less viable. In
the case of the box_count button layout part of the modal is displayed
atop the button, therefore constraining the iframe size looks extra
janky.
I don't know how to use PHP (and it's blocked on the site I'm editing actually) but in case it can help anyone else here's the final comment so far (posted yesterday)
Use the iframe version of the code, which you can get here:
https://developers.facebook.com/docs/plugins/like-button/ You need
the Javascript SDK loaded as well.
On the parent page, you need to use PHP to capture and store in a
session variable the complete URL of the parent page:
<?php $fburl = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://"; if ($_SERVER["SERVER_PORT"] != "80") {
$fburl .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else {
$fburl .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } session_start(); $_SESSION['savedurl'] = $fburl; ?>
Then, make the code to show the button(s) in the iframe like this:
<iframe src="//www.facebook.com/plugins/like.php?href=<?php session_start(); echo $_SESSION['savedurl']; ?>&width&layout=standard&action=like&show_faces=false&share=true&height=20&appId=your-app-id-goes-here" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:20px; width:330px;" allowTransparency="true"></iframe>
Change "your-app-id-goes-here" to your own appID.
This works because Facebook's iframe code is now contained within your
properly sized iframe, and therefore has no choice but to fit and stay
where it belongs...
There are names like Nike on the dev forum and it's still getting updated so hopefully further resolution's on the way – just thought I'd provide links and the latest available info here.