Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centering Buttons in HTML5 with CSS

I am wondering how I can center a group of social media buttons on my website.

I previously used the <center> tags, but switched to HTML5, so i have the centering property for my other text and images in the css. However I have links to 4 different social media sites who all use different coding styles to implement the button. The follow is my code


<-- 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>

<-- Twitter --> <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>


Is there a concise way of centering all of these items in HTML5? Or will I have to do it seperately for each? If that's the case, how can I center these items?

Thanks

EDIT: Sorry I left out, they are all contained within a container with the following properties .container { position: static;
height: 700px; width: 780px; top: 50%; left: 50%; margin: 10px;
margin-left: auto; margin-right: auto; }

Check out www.lacondesa.com.au/test.html to see

like image 221
dweeman Avatar asked Nov 30 '22 20:11

dweeman


2 Answers

Try putting the buttons inside a div with the style

text-align:center;
margin:auto;
like image 132
Dan Goodspeed Avatar answered Dec 03 '22 09:12

Dan Goodspeed


Give specific width inside a div and then put margin:auto.

div
{
width://your width;
margin:auto;
}
like image 24
Sasidharan Avatar answered Dec 03 '22 09:12

Sasidharan