如何从下至上开始文字?

时间:2018-06-29 12:08:25

标签: javascript html css

如何从下至上开始文字?

我需要

see image here

我尝试过:

.rotated {
  writing-mode: tb-rl;
  transform: rotateZ(-270deg);
}
<div class="rotated">
  <span>5000</span><br>
  <span>3000</span><br>
  <span>2000</span><br>
  <span>1000</span>
</div>

  

使用<br />可以轻松解决,但是在屏幕较小且<div>position: fixed;的情况下将无用。

2 个答案:

答案 0 :(得分:1)

只需更改添加项目的顺序并使用flex这样,即可:

.rotated {
  display: flex;
  height: 300px;
  flex-direction: column-reverse;
}
<div class="rotated">
  <span>1000</span>
  <span>2000</span>
  <span>3000</span>
  <span>5000</span>
</div>

答案 1 :(得分:0)

您可以将flexbox(display: flex)与align-items: flex-startjustify-content: flex-end结合使用。

.rotated {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  flex-direction: column;
  
  /* For demo */
  border: 1px solid black;
  height: 200px;
  width: 200px;
}
<div class="rotated">
  <span>5000</span><br>
  <span>3000</span><br>
  <span>2000</span><br>
  <span>1000</span>
</div>