Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting vertically middle in writing-modes

Tags:

html

css

I have a div with some text and writing-mode: vertical-rl. Now I want to this text be in the middle but vertical-align: middle; don't work even with setting line-height.

.a{
      background-color: coral;
      writing-mode: vertical-lr;
      min-height: 10em;
      vertical-align: middle;
      line-height: 2em;
  }
<div class="a">hiiiii<div>

How can I do this?

like image 721
n.y Avatar asked Dec 28 '16 06:12

n.y


2 Answers

use css3 flexbox concept,add the following codes to your style sheet ,it works fine

  display:flex;
  justify-content:center;
  align-items:center;

I'm added the snippet below.

.a{
      display:flex;
      justify-content:center;
      align-items:center;
      background-color: coral;
      writing-mode: vertical-lr;
      min-height: 10em;
      line-height: 2em;
  }
<div class="a">hiiiii<div>
like image 151
ADH - THE TECHIE GUY Avatar answered Oct 10 '22 03:10

ADH - THE TECHIE GUY


try using flexbox like this,

.a{
      display:flex;
      background-color: coral;
      writing-mode: vertical-lr;
      min-height: 10em;
      vertical-align: middle;
      line-height: 2em;
      justify-content:center;
      width:2em;
  }
<div class="a">hiiiii<div>
like image 22
Abood Avatar answered Oct 10 '22 01:10

Abood