As you can see at the picture below, the red lines representing the unequal width of each <td>
. My goal is the make each <td>
align evenly. How do I do that?
CSS
.stickyFooter {
background: #c1c1c1;
position: fixed;
left: 0;
right: 0;
bottom: 0;
height: 50px;
font-size: 13px;
}
Code
<div class="stickyFooter wrap visible-sm visible-xs table-responsive" style="margin-bottom: 0px; border: none;">
<table class="table">
<tr align="center">
<td><a href="#"><i class="fa fa-home fa-2x"></i><br>Home</a></td>
<td><a href="#"><i class="fa fa-bell fa-2x"></i><br>Notification</a></td>
<td><a href="#"><i class="fa fa-file-invoice-dollar fa-2x"></i><br>Transaction</a></td>
<td><a href="#"><i class="fa fa-search fa-2x"></i><br>Directory</a></td>
<td><a href="#"><i class="fa fa-newspaper fa-2x"></i><br>Ads</a></td>
<td><a href="#"><i class="fa fa-dollar-sign fa-2x"></i><br>Billing</a></td>
<td><a href="#"><i class="fa fa-plus fa-2x"></i><br>More</a></td>
<td><a href="#"><i class="fa fa-cogs fa-2x"></i><br>Setting</a></td>
</tr>
</table>
Image
The additional width is likely coming from the FontAwesome icons you have there, which have varying widths by default. This can be corrected by applying the class fa-fw
to each of the icons:
td { border: 1px solid black; min-width: 200px; }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <link href="https://use.fontawesome.com/releases/v5.0.7/css/all.css" rel="stylesheet" /> <div class="stickyFooter wrap visible-sm visible-xs table-responsive" style="margin-bottom: 0px; border: none;"> <table class="table"> <tr align="center"> <td><a href="#"><i class="fa fa-fw fa-home fa-2x"></i><br>Home</a></td> <td><a href="#"><i class="fa fa-fw fa-bell fa-2x"></i><br>Notification</a></td> <td><a href="#"><i class="fa fa-fw fa-file-invoice-dollar fa-2x"></i><br>Transaction</a></td> <td><a href="#"><i class="fa fa-fw fa-search fa-2x"></i><br>Directory</a></td> <td><a href="#"><i class="fa fa-fw fa-newspaper fa-2x"></i><br>Ads</a></td> <td><a href="#"><i class="fa fa-fw fa-dollar-sign fa-2x"></i><br>Billing</a></td> <td><a href="#"><i class="fa fa-fw fa-plus fa-2x"></i><br>More</a></td> <td><a href="#"><i class="fa fa-fw fa-cogs fa-2x"></i><br>Setting</a></td> </tr> </table> </div>
Keep in mind that <td>
cells will automatically expand to fill the available width of their <tr>
container, and your cells with longer text will 'want' to occupy more room in this regard. If you want to forcibly constrain (or expand) them, simply give them a defined width
.
This can also be seen in the above example, where I state that the cells must be at least 200px
wide each.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.