I just noticed today that the data-width attribute for the Facebook Like Box widget does not appear to be working. It looks like it is reverting to the default width. An example of what I'm talking about can be seen on
Use the iframe settings, in my site using the iframe settings with a likebox of 236px width and it overrules the 292px width.Brainless thinking of FB, every site needs a sidebar of 292px width???? yeye
facebook like box data-width 100
Here is what I used to fix it, this is not the exact same since I don't show faces, but just adapt it to your code, the important part is the div #fb-like-container that I added, it lets me use css selectors to change required code.
The accepted answer works for me only the first time that page is loaded, but after the browser is resized or I change from landscape to portrait in mobile devices the Facebook Plugin (version 3.2) doesn't adapt to my container. The solution for me was just check the Adapt to plugin container width, and add a listener to know when the page is resized then I remove the facebook iframe and load it again.
/* Vanilla JS */function setupFBframe(frame) var container = frame.parentNode; var containerWidth = container.offsetWidth; var containerHeight = container.offsetHeight; var src = " " + "?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook" + "&tabs=timeline" + "&width=" + containerWidth + "&height=" + containerHeight + "&small_header=false" + "&adapt_container_width=false" + "&hide_cover=true" + "&hide_cta=true" + "&show_facepile=true" + "&appId"; frame.width = containerWidth; frame.height = containerHeight; frame.src = src;/* begin Document Ready ############################################ */document.addEventListener('DOMContentLoaded', function() var facebookIframe = document.querySelector('#facebook_iframe'); setupFBframe(facebookIframe); /* begin Window Resize ############################################ */ // Why resizeThrottler? See more : (function() window.addEventListener("resize", resizeThrottler, false); var resizeTimeout; function resizeThrottler() if (!resizeTimeout) resizeTimeout = setTimeout(function() resizeTimeout = null; actualResizeHandler(); , 66); function actualResizeHandler() document.querySelector('#facebook_iframe').removeAttribute('src'); setupFBframe(facebookIframe); )(); /* end Window Resize ############################################ */);/* end Document Ready ############################################ */@import url(' =Indie+Flower');body font-family: 'Indie Flower', cursive;.container max-width: 1170px; width: 100%; margin-left: auto; margin-right: auto;.content overflow: hidden;.left_sidebar position: relative; float: left; width: 30%; max-width: 300px;.main_content position: relative; float: left; width: 70%; background-color: #DDEFF7;/* ------- begin Widget Facebook -------------- */.widget--facebook--container padding: 10px; border: 1px solid #000;.widget-facebook height: 500px;.widget-facebook .facebook_iframe border: none;/* ---------- end Widget Facebook---------------- *//* ----------------- no need -------------------- */.block color: #fff; height: 300px; background-color: #00A7F7; border: 1px solid #005dff;.block h3 line-height: 300px; text-align: center; Content Content Responsive width Facebook Page Plugin Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab.
@import url(' =Indie+Flower');body font-family: 'Indie Flower', cursive;.container max-width: 1170px; width: 100%; margin-left: auto; margin-right: auto;.content overflow: hidden;.left_sidebar position: relative; float: left; width: 30%; max-width: 300px;.main_content position: relative; float: left; width: 70%; background-color: #DDEFF7;/* ------- begin Widget Facebook -------------- */.widget--facebook--container padding: 10px; border: 1px solid #000;.widget-facebook height: 500px;.widget-facebook .facebook_iframe border: none;/* ---------- end Widget Facebook---------------- *//* ----------------- no need -------------------- */.block color: #fff; height: 300px; background-color: #00A7F7; border: 1px solid #005dff;.block h3 line-height: 300px; text-align: center; Content function setupFBframe(frame) if (frame.src) return; // already set up var container = frame.parentNode; console.log(frame.parentNode); var containerWidth = container.offsetWidth; var containerHeight = container.offsetHeight; var src = " " + "?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook" + "&tabs=timeline" + "&width=" + containerWidth + "&height=" + containerHeight + "&small_header=false" + "&adapt_container_width=false" + "&hide_cover=true" + "&hide_cta=true" + "&show_facepile=true" + "&appId"; frame.width = containerWidth; frame.height = containerHeight; frame.src = src; var facebookIframe; /* begin Window Resize ############################################ */ // Why resizeThrottler? See more : (function() window.addEventListener("resize", resizeThrottler, false); var resizeTimeout; function resizeThrottler() if (!resizeTimeout) resizeTimeout = setTimeout(function() resizeTimeout = null; actualResizeHandler(); , 66); function actualResizeHandler() document.querySelector('#facebook_iframe').removeAttribute('src'); setupFBframe(facebookIframe); )(); /* end Window Resize ############################################ */ Content Responsive width Facebook Page Plugin Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum earum, temporibus, maxime repudiandae obcaecati veritatis, odio dolore provident tenetur perferendis ipsam, rem esse vitae laudantium voluptatem iste aliquam optio ab. 2ff7e9595c
Comments