vertically text for the label in the header column

2019-04-26 12:02发布

I am trying to make a table with Vertical Text just on the header table.

enter image description here

Here is my CSS code:

table th.user {
  .rotate(90deg);
  position: relative;
  padding-top: 190px;
  top: -10px;
  right: 0px;
  width: 200px;
}

Here is the demo http://codepen.io/anon/pen/GnveJ

As you can see it works partially. I would like to have the columns (the cells of the column where there are the name) which width fits exactly the contents (about 50 px); the same as the pic I attached to this question.
Any idea what is the best way to make the css code or js code for this purpose?

Requirement:
I am using less and jquery

1条回答
地球回转人心会变
2楼-- · 2019-04-26 12:40

Wrap the username in a span, rotate that, and set a width on the cells. If you rotate the cells, the table will render its size before it rotates the text.

table th.user span{
  display:block;
  .rotate(90deg);
  padding: 190px 0 0 0;
  position: relative;
  left: 20px;
  width: 200px;
}
.user, tbody td {
  max-width: 50px;
}

Demo

查看更多
登录 后发表回答