1

I have a table cell with a text and icon:

.icon {
  float: right;
  margin-right: 5px;
}
<td class="table_cell">
  <span>
    Some text
    <i class="icon"></i>
  </span>
</td>

Chrome displays them vertically aligned to each other, Firefox display the text on the upper left and icon lower right corner.

How can I fix that, thanks!!

Durga
  • 15,263
  • 2
  • 28
  • 52
Theano T
  • 61
  • 7

1 Answers1

0

You can use flexbox to provide your table cell content vertical centering. Demo:

.table_cell > span {
  /* become a flex-container */
  /* all children will be flex-items including plain text */
  display: flex;
  /* vertically center items */
  align-items: center;
}

.icon {
  /* move icon to the right */
  margin-left: auto;
  margin-right: 5px;
]
<td class="table_cell">
  <span>
    Some text
    <i class="icon"></i>
  </span>
</td>
Vadim Ovchinnikov
  • 13,327
  • 5
  • 62
  • 90