alignment - How to center a div horizontally in a table using CSS -
i updated clarity.
so have buttons have created consist of circle , font-awesome icon. each of these buttons link social media. want put these buttons inside table row, each horizontally , vertically aligned center of each table cell. how horizontally align them?
here html:
<!doctype html> <html lang="en"> <head> <script src="https://use.fontawesome.com/604215ea7e.js"></script> <style> .social_icon { width: 40px; height: 40px; border-radius: 50%; background-color: #ccc; text-align: center; display: table-cell; vertical-align: middle; } .social_icon:hover { background-color: #999; cursor: pointer; } #footer_social_icons { width: 20%; height: 80px; background-color: #636363; text-align: center; } #footer_social_icons table { width: 100%; height: 80px; } #footer_social_icons td { vertical-align: middle; border: 1px solid #fff; /* show not centred */ } </style> </head> <body> <div id="footer_social_icons"> <table> <tr> <td> <div class="social_icon"> <i class="fa fa-google-plus" aria-hidden="true"></i> </div> </td> <td> <div class="social_icon"> <i class="fa fa-facebook" aria-hidden="true"></i> </div> </td> <td> <div class="social_icon"> <i class="fa fa-twitter" aria-hidden="true"></i> </div> </td> <td> <div class="social_icon"> <i class="fa fa-envelope" aria-hidden="true"></i> </div> </td> </tr> </table> </div> </body> </html>
try below code..
do in every tag , add below code in css
<td> <div class="socicon"> <div class="social_icon"> <i class="fa fa-google-plus" aria-hidden="true"></i> </div> </div> </td> .socicon { margin: 0 auto; text-align: center; width: 57%; // have adjust width requirement }
Comments
Post a Comment