How to hide Facebook’s Like Box social plugin border

Posted: May 26th, 2010 | Author: | Filed under: Web Development | Tags: , , , | 8 Comments »

I was trying to make my own rounded-colored-cooler-looking border for the Like Box social plugin, and Facebook’s default border was getting in the way.

That’s what I eventually used:

<div id="likebox" style="background-image: url(../images/likebg.png); width: 286px; height: 156px; padding: 7px;">
	<div id="likebox-frame" style="width: 286px; height: 156px; overflow: hidden;">
		<iframe style="width: 288px; height: 155px; margin: -1px -4px 0 -4px;" frameborder="0" border="0" src="http://www.facebook.com/plugins/likebox.php?id=185550966885&amp;width=300&amp;connections=5&amp;stream=false&amp;header=false&amp;height=255" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
	</div>
</div>

So – what does it do?

  • We have the #likebox element that sets the background image (that has rounded borders) and some padding, so the content won’t hide the border.
  • The #likebox-frame element is just a dummy container to make the negative margins on the actual iframe (see below) work while the padding of #likebox still pushes the content inside. it needs height/width of the actual likebox content after removing the borders, which should be the same as #likebox inner height/width
  • And now – for the actual iframe – we have 4 borders that facebook adds inside the iframe to hide. The top/left borders are hidden with a negative margin (top margin of -1px and left margin of -4px”) and the bottom/right borders are hidden because the iframe is bigger than its container – so it pushes it outside and the #likebox-frame overflow:hidden takes care of hiding it.

That’s it. Worked out quite nicely.


8 Comments on “How to hide Facebook’s Like Box social plugin border”

  1. 1 kentos said at 12:33 pm on June 17th, 2010:

    Genious!

    Soo simply, but so helpful :)

  2. 2 myCampbell.de erhält Feinschliff | myCampbell.de - Das Campbell-Zwerghamster Blog said at 3:35 pm on August 16th, 2010:

    [...] (gefunden bei der Blogwiese), Cute Profiles deaktiviert, die Facebook-Like-Box eingebaut (die Border im iframe bekommt man übrigens leicht weg) und die Twitter- und Facebook-Boxen sind nun auch im [...]

  3. 3 facebook like box keret | kobak pont org said at 6:01 am on October 14th, 2010:

    [...] guglizás után itt leltem rá a megoldásra. window.fbAsyncInit = function() { FB.init({appId: "", status: true, [...]

  4. 4 walid said at 11:03 am on March 23rd, 2011:

    Perfect, Thank you :)

  5. 5 Zypcon said at 1:15 pm on July 19th, 2011:

    worked fine
    thank you

  6. 6 Mohamed Elgharabawy said at 3:11 pm on September 29th, 2011:

    I found this useful sometime ago, however, the new Facebook like box is a little bit different. I have written a post about this on my blog, you can see it here:

    http://itscoding.com/change-facebook-like-box-border-color

    Thanks for the post.

  7. 7 Martin said at 12:05 pm on January 17th, 2012:

    Thank for the info – still works fine.

  8. 8 shesek said at 4:42 pm on January 17th, 2012:

    @Martin – I’m glad to hear that. Been quite a while since I published it :-)


Leave a Reply