herrh herrh - 3 months ago 29
jQuery Question

How to center a facebook iframe like button

I'm not able to center facebook like buttons in a single global solution. The facebook like button width variables for different languages. So I need a global solution to center facebooks iframe like button inside a div.


Important: I can't use the Facebook Javascript SDK Button in this
project.


enter image description here
enter image description here

Because of the unknown width of the button for every language and the number of likes I don't know a possible solution to center the button inside a div.



.mydiv {
padding: 30px 0;
background: red;
}

iframe {
background: green;
}

<div class="mydiv">
<iframe src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&width=126&layout=button_count&action=like&size=small&show_faces=false&share=false&height=21&appId=848263035268773" width="126" height="21" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
</div>




Answer
.mydiv {
  padding: 30px 0;
  background: red;
  text-align:center;
}

Add text-align:center to your containing div.