3

I am building a web page layout using blocks set to display: table-cell. Everything is working fine, but I cannot flip the cells (change their order) in a row and wondering if there is such possibility or some trick what I can use to achieve this.

I need to achieve this using only CSS and display: table-cell :)

Thanks in advance for any suggestions.

HTML

<div class="dtc">
    <div>Item1</div>
    <div>Item2</div>
</div>

CSS

.dtc{
    display: table;
    width: 100%;
}
.dtc > *{
    display: table-cell;
}

Current table:

+-------+-------+
| Item1 | Item2 |
+-------+-------+

Desired result:

+-------+-------+
| Item2 | Item1 |
+-------+-------+
egurb
  • 1,176
  • 2
  • 14
  • 40
  • Have a look here: http://stackoverflow.com/questions/220273/use-css-to-reorder-divs - you can do so with flexbox / order css3 property – eithed Jun 19 '16 at 19:51

1 Answers1

22

use RTL for parent and LTR for children. This will flip the order .

.dtc { direction: rtl; }
.dtc > div { direction: ltr; }

Without LTR for children text will not be properly aligned.

Ilya Novojilov
  • 871
  • 8
  • 12