我有一个简单的表格单元格,其中包含文本和图标.我想对齐左侧的文本和右侧的图标.我试过这样,但它不起作用.我知道的唯一解决方案是创建另一个td,我把图标放在里面.但我想要一个td中的文本和图标
table {
border: 1px solid red;
}
td {
border: 1px solid black;
width: 200px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<table>
<tr>
<td>Text <span align="right"><i class="fa fa-toggle-on"></i></span></td>
<td>Test</td>
</tr>
</table>
最佳答案
尝试使用
style="float:right;"
像这样:
table {
border: 1px solid red;
}
td {
border: 1px solid black;
width: 200px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<table>
<tr>
<td>Text <span style="float:right;"><i class="fa fa-toggle-on"></i></span></td>
<td>Test</td>
</tr>
</table>
此外,正如webeno在评论中正确指出的那样,align attribute has been deprecated now.所以尽量避免它.
相关文章
转载注明原文:html – 在表格单元格中右对齐图标? - 代码日志