Facebook Like-Button - hide count?

后端 未结 15 642
我寻月下人不归
我寻月下人不归 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:41

    Just encompass the iframe in a div set the width to the width of button, set overflow to hidden i.e.

      <div style="width:52px;overflow:hidden;">
          <fb:like layout="button_count"></fb:like>
    
          <div id="fb-root"></div>
              <script>
                  window.fbAsyncInit = function() {
                      FB.init({
                        appId: 'YOUR_APP_ID',
                        status: true,
                        cookie: true,
                        xfbml: true
                      });
                  };
                  (function() {
                      var e = document.createElement('script');
                      e.type = 'text/javascript';
                      e.src = document.location.protocol +
                      '//connect.facebook.net/en_US/all.js';
                      e.async = true;
                      document.getElementById('fb-root').appendChild(e);
                  }());
              </script>
          </div>
    
    0 讨论(0)
  • 2020-11-29 18:41

    Facebook now supports hiding the count, use this in the markup:

    data-layout="button"
    
    0 讨论(0)
  • 2020-11-29 18:43

    I know many solutions have been posted already, but mine is still somewhat different. It works for the HTML5 Version of the like button and only uses css to hide the count box. Don't forget to add the appId to test.

    CSS:

    <style type="text/css">
        .fb-like span {
            display: block;
            height: 22px;
            overflow: hidden;
            position: relative;
            width: 140px /* set this to fit your needs when support international sites */;
        }
    
        .fb-like iframe {
            height: 62px;
            overflow: hidden;
            position: absolute;
            top: -41px;
            width: 55px;
        }
    </style>
    

    FB Like Button:

    <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_GB/all.js#xfbml=1&appId=xxxxxxxxxxxx";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    
    <div class="fb-like" data-send="true" data-layout="box_count" data-width="450" data-show-faces="false"></div>
    
    0 讨论(0)
  • 2020-11-29 18:43

    My solution is a little hood but it works. What I do is just basically detect where the number is going to be and use css to have a box cover over it. I guess you can also cheat the system and add more hits if you want. Here is my code using jquery but it will be different than others depending on where you place the like button on your page.

    Not the most glamorous but hey the security is to tight to manipulate content in side of a frame.

    <script type="text/javascript">
        var facebook_load = '';
        $(document).ready(function() {
            facebook_load = setInterval('checkIframeFacebookLoad()',100);
        });
    
        function checkIframeFacebookLoad() {
            if($('iframe.fb_ltr').length) {
                var parent = $('iframe.fb_ltr').parent();
                var hide_counter = $('<div></div>').attr('id', 'hide_count');
                parent.append(hide_counter);
                clearInterval(facebook_load);
            }
        }
    </script>
    
    <style type="text/css">
        #hide_count {
            position:absolute;
            top:-8px;
            left:122px;
            background:#becdd5;
            padding:5px 10px; 
        }
    </style>
    
    0 讨论(0)
  • 2020-11-29 18:44

    this worked for me:

    .fb-like.fb_edge_widget_with_comment.fb_iframe_widget {
        height: 26px;
        overflow: hidden;
        width: 138px;
    }
    
    0 讨论(0)
  • 2020-11-29 18:45

    The Like button coded to show "Recommend" is 84px wide and the "Like" button is 44px, will save some time for you CSS guys like me who need to hide how unpopular my page currently is! I put this code on top of my homepage, so initially I don't want it to advertise how few Likes I have.

    0 讨论(0)
提交回复
热议问题