2013-10-22 32 views
5

我在想如何將一組社交媒體按鈕置於我的網站上。使用CSS定位HTML5中的按鈕

我以前使用<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/[email protected]); 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>

< - 的tumblr - ><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看到

回答

12

嘗試把按鍵一個div裏面的風格

text-align:center; 
margin:auto; 
+0

工作完美!非常感謝 – dweeman

+0

'margin:auto;'真的需要嗎? – smartmouse

+1

'margin:auto'行中心div。 –

2

給一個DIV中特定的寬度,然後把margin:auto

div 
{ 
width://your width; 
margin:auto; 
} 
1

這可能工作。試試,

margin : 0px auto;