Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 890
Dmitry Avatar asked Oct 19 '16 13:10

Dmitry


People also ask

What is the writing-mode of vertical text?

Vertical text is common in graphic design, and can be a way to add a more interesting look and feel to your web design. The three possible values for the writing-mode property are: horizontal-tb: Top-to-bottom block flow direction. Sentences run horizontally. vertical-rl: Right-to-left block flow direction. Sentences run vertically.

How do I show all the writing modes in HTML?

For CSS, use vertical-rl instead. This example demonstrates all of the writing modes, showing each with text in various languages. The HTML is a <table> with each writing mode in a row with a column showing text in various scripts using that writing mode.

What is the difference between horizontal-TB and vertical writing mode?

When we switch the writing mode, we are changing which direction is block and which is inline. In a horizontal-tb writing mode the block direction runs from top to bottom; in a vertical-rl writing mode the block direction runs right-to-left horizontally.

How to rotate text vertically in a Div?

This should be enough to rotate text vertically from bottom to top, apply it on div containing the text. If you are using writing-mode: vertical-rl/lr in conjunction to this, that may be switching it to other way around. Show activity on this post.


1 Answers

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/

like image 169
Michael Benjamin Avatar answered Sep 21 '22 18:09

Michael Benjamin