Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Like Button Causing Horizontal Scrollbar

I've recently added a facebook like button to my site and it's causing a horizontal scrollbar to appear when it's not needed. It doesn't appear in Chrome but is there in Firefox and IE.

I've checked the created code in Firebug and can't see what's going wrong.

Here's a link to the site so you can see: http://www.swiftfurniture.com/

As you can see, on Firefox and IE (possibly other browsers too), there's a horizontal scrollbar when it isn't needed. It's definitely the Facebook like button causing it, because when I comment that out, they disappear.

I've added a fixed width div around the button with overflow: hidden applied, but it seems to ignore that.

I know there's plenty of other questions similar to this, but with using PrestaShop I don't really want to mess around with the core code too much just to get a Facebook Like button working (if at all possible). I was hoping for a solution to keep all the code contained to the "social module" I've created... i.e - just one file rather than messing around with header files etc of PrestaShop.

like image 798
BT643 Avatar asked Mar 21 '12 16:03

BT643


People also ask

Why am I getting a horizontal scrollbar?

Web browsers do not take into account the width of the scrollbar on the side of a page when computing width values, so since we have a page that is longer than a single viewport, part of our page is being rendered behind the vertical scroll bar, causing the browser to display a horizontal scroll bar.

Did Facebook Change the like button?

Facebook has removed the like button from its redesigned public pages used by artists, public figures and brands, the social media company said on Wednesday. This is a pretty big change and now it will instead focus more on the news feed for conversations, rather than highlighting the likes on FB pages.


3 Answers

I've looked into your problem a bit with Firebug and can share some observations that might be helpful.

There is code that is being injected into your <div id="fb-root"></div> and within that is an iframe with an inline style width of 575px.

That is what is causing the scrollbars.

like image 131
redlena Avatar answered Nov 09 '22 22:11

redlena


You can add to the "fb-like" attribute data-width="100px"

like image 4
user2722034 Avatar answered Nov 09 '22 21:11

user2722034


The mark-up Facebook inserts into your page is liable to change so you want to use a solution that is not dependent on it.

You can resolve this issue by placing the fb-root div as the first child of your body element

<body>
    <div id="fb-root"></div>

The script tag and fb-like div can remain in their original place.

Ref: Facebook documentation and bug report

like image 3
scarba05 Avatar answered Nov 09 '22 20:11

scarba05