Can't manipulate width of Facebook Like Button

核能气质少年 提交于 2020-01-06 07:47:10

问题


I have a sidebar 200px wide and the Facebook Like button I have placed inside it is running outside the boundaries of the DIV. Are there any workarounds to get the Like box text to recognise the 200px mark and reflow onto new lines when needed?

I am working with this code: http://jsfiddle.net/tKkpm/2/

<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=437745402932329";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="http://www.facebook.com/google" data-send="false"
 width="200" data-show-faces="false"></div>

回答1:


I'll put my comment as an answer...

The Facebook Like Button documentation states that the minimum width has to be 225 pixels.

The reason it can sometimes be less than that, is because you can use an iframe. Although smaller widths aren't fully supported, it does seem to work!

<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fgoogle&amp;send=false&amp;layout=standard&amp;width=200&amp;show_faces=false&amp;font&amp;colorscheme=light&amp;action=like&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:35px;" allowTransparency="true"></iframe>

Please note that you will have to set the width in two different places!




回答2:


The like box width is a problem. I have used overflow:hidden in CSS to make it work at the left sidebar at http://www.mineoppskrifter.no. The problem here is that the images are cut, but at least the width is ok.

#sidebar-left .fb-like-box  {
width: 187px !important;
overflow:hidden;
}

Change #sidebar-left to the name of your div.



来源:https://stackoverflow.com/questions/14539092/cant-manipulate-width-of-facebook-like-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!