Remove white space beneath Facebook comments plugin

后端 未结 7 1122
逝去的感伤
逝去的感伤 2021-02-06 04:41

Take a look at the this link. Scroll down a bit and you should see a Facebook comments plugin with an embedded Google map right beneath it.

My problem is, there is a ton

7条回答
  •  半阙折子戏
    2021-02-06 05:24

    I was suffering from the same problem. The extra white space only shows up when there are no comments yet. So you just simply do the following:

    1.) Swap back to the old markup, because step 2) is not supported by HTML5

    2.) Make a new div #commentcount, in which you will load the count of comments. You can hide it with display:none;.

    3.) Insert the following code to #commentcount: , where example.com is the exact URL of where you're commenting. In most cases this will be $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"] (PHP), or the appropriate HTTP header variables in other languages.

    4.) Store the comment count in a variable in JavaScript. You can reach the count easily, It's inside the #commentcount div in a span element. If you're not sure about this, check chrome dev tools or firebug, it will show you the rendered structure. (as facebook may change it eventually)

    5.) Write a nice javascript code to update the facebook comment container div if(commentcount==0). Add a style of: height:110px; overflow:hidden;.

    6.) Load the comment count frequently so if someone comments, you can drop the hidden overflow and fixed height, and they can see the new comment. You can do this using setInterval().

    It works!

    An easier alternative solution: You can set the style="background-color:#f5f5f5;" for the comments box if you have for example a site with F5F5F5 background color. The comments box colour will blend into your site. It looks nice.

提交回复
热议问题