How to center a facebook iframe like button

I need a global solution to center a facebook iframe like button which can have different like urls and different locales (and languages - in my case 40+). So the button will have different widths in the end.

According to that I removed the width attribute and added the locale param. The iframe gets 300px wide and its not possible to center it.

See the problem in this example:

.mydiv {
  padding: 30px 0;
  background: red;
  text-align: center;
}
.mydiv span {
  font-family: sans-serif;
  text-decoration: underline;
  display: block;
  margin-bottom: 10px;
}
.mydiv iframe {
  background: green;
}
<div class="mydiv">
  <span>locale en_US</span>
  <iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&layout=button_count&action=like&size=small&show_faces=true&share=false&height=21&appId=848263035268773" height="21" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>

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

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

text-align:center添加到您的包含div。

链接地址: http://www.djcxy.com/p/62302.html

上一篇: AUGraph回调延迟

下一篇: 如何中心一个Facebook的iframe像按钮