How can I properly rotate a text inside a table cell

前端 未结 1 1708
隐瞒了意图╮
隐瞒了意图╮ 2021-01-19 06:16

I tried to create a classic HTML table with a title top and left. Now I want to rotate the text in the left title by -90°.

Css only supports 90° wit

1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-19 06:50

    You can use writing-mode: vertical-rl; combined with a scale transformation:

    table {
      text-align: left;
      border-collapse: collapse;
    }
    
    td,
    th {
      border: 1px solid lightgrey;
      padding: 0px 3px;
    }
    
    td:not(:first-child) {
      min-width: 140px;
    }
    
    .table_title_top {
      text-align: center;
    }
    
    .table_title_left {
      text-align: center;
      width: 35px;
    }
    
    .table_title_left div {
       writing-mode: vertical-rl;
       white-space:nowrap;
       transform:scale(-1);
    }
    
    
    
    
      
    
    
    
      
    Title Top Title Top
    Title Left Title Left
    0 0 0
    0 0 0
    0 0 0

    0 讨论(0)
提交回复
热议问题