Dmitry Dmitry - 1 month ago 7
CSS Question

Set writing mode / text direction bottom to top

I can't find a solution to make the green elements start at the bottom right of the container, like in right image ("Need").

Does CSS provide a way to align/orient elements from the bottom?

"Default" and "Need" element's location illustrated.

enter image description here

SNIPPET



.cnt {
width:200px;
height:300px;
border:1px solid green;
text-align:center;
display: table-cell;
vertical-align: bottom;
}

.itm {
transform: translate(0px, 0px) scale(1);
display: inline-block;
padding:10px;
width:20px;
margin:10px;
background: green;
color: white;
transition:transform 0.5s;
}
.itm:hover {
transform: translate(0px, -3px) scale(1.1);
}

<div class="cnt">
<div class="itm">1</div>
<div class="itm">2</div>
<div class="itm">3</div>
<div class="itm">4</div>
<div class="itm">5</div>
<div class="itm">6</div>
<div class="itm">7</div>
<div class="itm">8</div>
</div>




Answer

Does CSS provide a way to align/orient elements from the bottom?

Surprisingly, in horizontal writing mode, it doesn't appear so.

There are various properties, including writing-mode, direction, text-orientation and flex-direction, that allow you to re-arrange the flow of content.

But none of them appear to allow the laying out of content in a horizontal writing mode starting from the bottom right. Maybe somebody could correct me on this.

In the meanwhile, here's a hack (pure CSS):

.cnt {
  display: flex;
  flex-direction: row-reverse;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  justify-content: center;
  text-align: center;
  width: 200px;
  height: 300px;
  border: 1px solid green;
  transform: scaleY(-1);
}
.itm {
  padding: 10px;
  width: 20px;
  margin: 10px;
  background: green;
  color: white;
  transform: translate(0px, 0px) scaleY(-1) scaleX(1);
  transition: transform 0.5s;
}
.itm:hover {
  transform: translate(0px, -3px) scaleY(-1.1) scaleX(1.1);
}
<div class="cnt">
  <div class="itm">8</div>
  <div class="itm">7</div>
  <div class="itm">6</div>
  <div class="itm">5</div>
  <div class="itm">4</div>
  <div class="itm">3</div>
  <div class="itm">2</div>
  <div class="itm">1</div>
</div>

https://jsfiddle.net/o7hr07k6/