I have a simple table cell that contains 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 will not work. The only solution I know is to create another one tdwhere I put the icon inside. But I want both the text and the icon in onetd
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>
Try using
style="float:right;"
like this:
<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>
As in the comments on the website, the attribute is now deprecated. . So try to avoid this.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> <table> <tr> <td>Text <span ><i class="fa fa-toggle-on pull-right"></i></span></td> <td>Test</td> </tr> </table>
This is the best way, I think ...
, .
span { float: right; }
:
table { border: 1px solid red; } td { border: 1px solid black; width: 200px; } td > span { float: right; }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> <table> <tr> <td>Text <span><i class="fa fa-toggle-on"></i></span></td> <td>Test</td> </tr> </table>
<style> /*If not using bootstrap add this to you css*/ .pull.right{ float:right; } <table width="100%"> <tr> <td>Text <span><i class="fa fa-toggle-on pull-right"> </i></span></td> <td>Test</td> </tr> </table>
If you want them to be in the same td (without adding another for the icon), you can try the following:
<td> <div style="float:left;width:50%;">I stay at left</div> <div style="float:right;width:50%;">And I stay at right</div> </td>
add another class to your css
table i.fa{ float: right; }
Source: https://habr.com/ru/post/1627408/More articles:Как написать API-интерфейс Node.js express для загрузки файлов? - node.jsUnix shell scripts: pass shell parameters (-x, etc.) to nested scripts - linuxjQuery приращение или уменьшение переменной на 1 - javascriptRstudio: setting TO DOs - rTabControl Single Line TabPanel and Overflow Panel - wpfДобавление новой таблицы в модель (edmx) без обновления других моделей в приложении MVC First First Entity Framework - c#Python runtime if substring in string - pythonPython string 'in' operator implementation algorithm and time complexity - pythonPython - search function () - pythonJava initializes a class in style, as in C # - javaAll Articles