How to center text horizontally and vertically in cojunction with 'writing-mode: sideways-lr'?

可紊 提交于 2021-02-17 03:28:33

问题


I have a TD/DIV with some text inside. I made so that the text is displayed in the center of TD/DIV . But I want the text to be in center using writing-mode: sideways-lr. How can I do this?

div {
  width: 200px;
  height: 100px;
  text-align: center;
  vertical-align: middle;
  border: solid;
  display: table-cell;
}

.side {
  writing-mode: sideways-lr;
}
<div>My text</div>
<br>
<div class="side">My text</div>

Code here


回答1:


Consider an extra span where you apply the property and better use writing-mode: vertical-rl;transform: scale(-1); to have better support (your code works only on Firefox actually)

div {
  width: 200px;
  height: 100px;
  text-align: center;
  vertical-align: middle;
  border: solid;
  display: table-cell;
}

.side span {
  /* writing-mode: sideways-lr; */
  writing-mode: vertical-rl;
  transform: scale(-1);
}
<div>My text</div>
<br>
<div class="side"><span>My text</span></div>


来源:https://stackoverflow.com/questions/60958648/how-to-center-text-horizontally-and-vertically-in-cojunction-with-writing-mode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!