我有一个简单的表格单元格,其中包含一个文本和一个图标。我想对齐左侧的文本和右侧的图标。我试过这样,但它不起作用。我知道的唯一解决方案是创建另一个 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 - 在表格单元格中将图标右对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35219871/