本文介绍了在表格单元格中右对齐图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的表格单元,其中包含文本和图标。我想将左侧的文本和右侧的图标对齐。我这样尝试过,但是没有用。我知道的唯一解决方案是在图标中放入另一个 td
。但是我想要文本和图标都放在一个 td
I have a simple table cell which contains a text and an icon. I want to align the text on the left and the icon on the right. I tried it like this, but it does not work. The only solution i know would be to create another td
where i put the icon inside. But i want both, text and icon in one 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在评论中正确指出的那样, 因此,请避免使用它。
Also as webeno has correctly pointed out in comments, the align attribute has been deprecated now. So try to avoid it.
这篇关于在表格单元格中右对齐图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!