4

我想知道如何将一组社交媒体按钮集中在我的网站上。

我以前使用过<center>标签,但切换到 HTML5,所以我在 css 中拥有其他文本和图像的居中属性。但是,我有 4 个不同的社交媒体网站的链接,它们都使用不同的编码风格来实现按钮。以下是我的代码


<-- FB--> <div class="fb-like" data-href="https://www.facebook.com/pages/La-Condesa/242967619184322" data-width="20" data-height="20" data-colorscheme="light" data-layout="standard" data-action="like" data-show-faces="false" data-send="false"></div>

<-- Instagram --> <style>.ig-b- { display: inline-block; } .ig-b- img { visibility: hidden; } .ig-b-:hover { background-position: 0 -60px; } .ig-b-:active { background-position: 0 -120px; } .ig-b-32 { width: 32px; height: 32px; background: url(//badges.instagram.com/static/images/ig-badge-sprite-32.png) no-repeat 0 0; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min--moz-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2 / 1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) {.ig-b-32 { background-image: url(//badges.instagram.com/static/images/ig-badge-sprite-32@2x.png); background-size: 60px 178px; } }</style><br><br>

<a href="http://instagram.com/lacondesafitzroy?ref=badge" class="ig-b- ig-b-32">img src="//badges.instagram.com/static/images/ig-badge-32.png" alt="Instagram" /></a>

<-- 推特 --> <a href="https://twitter.com/LaaCondesa" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @LaaCondesa</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

<-- 微博--><iframe class="btn" frameborder="0" border="0" scrolling="no" allowtransparency="true" height="25" width="114" src="http://platform.tumblr.com/v1/follow_button.html?button_type=2&tumblelog=LaaCondesa&color_scheme=light"></iframe>


有没有一种简洁的方法可以在 HTML5 中将所有这些项目居中?还是我必须为每个单独做?如果是这种情况,我怎样才能使这些项目居中?

谢谢

编辑:对不起,我遗漏了,它们都包含在具有以下属性的容器中 .container { position: static;
height: 700px; width: 780px; top: 50%; left: 50%; margin: 10px;
margin-left: auto; margin-right: auto; }

查看 www.lacondesa.com.au/test.html 以了解

4

3 回答 3

16

尝试将按钮放在具有样式的 div 中

text-align:center;
margin:auto;
于 2013-10-22T05:16:22.900 回答
2

在 div 中指定特定宽度,然后将margin:auto.

div
{
width://your width;
margin:auto;
}
于 2013-10-22T05:22:03.537 回答
1

这可能有效。尝试,

margin : 0px auto;
于 2013-10-22T05:24:24.390 回答