Facebook Like-Button - hide count?

后端 未结 15 779
我寻月下人不归
我寻月下人不归 2020-11-29 18:17

In the setup dialog for the Like-Button, there are only two options for layout:

  • Alternative 1
  • Alternative 2

Unfortunately, the numbers

15条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 18:53

    It seems as if FaceBook has recently changed some code - whenever I clicked "Like", the contents jumped to the left, thus messing up the UI. No CSS / JS tricks made it work. I went with a more simple solution, using an iframe.

    NOTICE - Though some devices already support iFrames, not all mobile devices do. iFrames are actually old and not recommended at all, but it did the trick for me.

    Lets take the default like-generation script from facebook, and generate an iFrame like box;

    Click here to generate like button

    Go for the "Box_Count" style, with a counter on top.

    When you press "Grab the code", go for the iFrame code. You'll get something similar to this;

    
    

    Now lets wrap a div around there.

    
    

    Give it the following CSS:

    .like_wrap {
        width:55px;
        height:25px;
        overflow:hidden;
    }
    

    Now you'll probably see the left top corner of the counter. Now we have to fix the iFrame. Give it a class;

    
    

    And make it so that it is always english, by adding "&locale=en_US" to the URL. This is to prevent weird layouts in other countries - in Dutch it would be "Vind ik leuk" and in english "Like". I guess everybody, in every language, knows a "Like" so lets stick with that.

    Now we'll add some more CSS for the like_box;

    .like_box {
        margin-top:-40px;
    }
    

    So the whole code looks like this (i've removed the app_id as I didn't need it)

    HTML:

    
    

    CSS:

    .like_wrap {
        width:55px;
        height:25px;
        overflow:hidden; 
    }
    
    .like_box {
        margin-top:-40px;
    }
    

    And now i have a decent, small, like box, that works fine and doesn't jump around. Let me know how this works out for you and if there are any problems that you are facing.

提交回复
热议问题