Balancing on a Pivot with Flexbox

A two dimensional series of words, laid out in intersecting boxes like in a crossword puzzle.

Let me show you a way I recently discovered to center a bunch of elements around what I call the pivot. I promise you that funky HTML is out of the question and you won’t need to know any bleeding-edge CSS to get the job done.

[…]

[H]ere’s a sample of the HTML that drives this puzzle:

Code language: HTML

<div class="puzzle">
  <div class="word">
    <span class="letter">i</span>
    <span class="letter">n</span>
    <span class="letter">d</span>
    <span class="letter">i</span>
    <span class="letter pivot">g</span>
    <span class="letter">o</span>
  </div>
  <!-- MORE WORDS -->
</div>

Here’s a generalized version of the [styles]. As you can see, it’s just 15 lines of simple CSS:

Code language: CSS

.puzzle .word {
  display: flex;
}
.puzzle .word .letter:last-child {
  margin-right: auto;
}
.puzzle .word .letter {
  order: 2;
  position: relative;
  right: 50%;
}
.puzzle .word .pivot,
.puzzle .word .pivot ~ .letter {
  order: 1;
  left: 50%;
}