html - <th> 标签内的 CSS 旋转纯文本

标签 html css html-table css-transforms

我试图在 一些 th 单元格内旋转文本 -90 度:

.th-vert {
  -webkit-transform: rotate(-90deg);
}
<table class="table table-striped" border="1">
  <thead>
    <tr>
      <th>0000</th>
      <th class="th-vert">0000</th>
      <th class="th-vert">0000</th>
      <th class="th-vert">0000</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>0</td>
      <td>0</td>
      <td>0</td>
      <td>0</td>
    </tr>
  </tbody>
</table>

问题是我的浏览器似乎在旋转整个 th 元素...这意味着它的宽度似乎变成了新的高度...请注意下面的 th 出现在它之后的行下方:

enter image description here

我希望第 th 只需调整其大小/形状以适应垂直文本,这可能吗?

最佳答案

你可以看看writing-mode :

.th-vert {
 writing-mode:vertical-rl;
 padding:0 1.25em 0 0;
}
<table class="table table-striped" border="1">
  <thead>
    <tr>
      <th>0000</th>
      <th class="th-vert">0000</th>
      <th class="th-vert">0000</th>
      <th class="th-vert">0000</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>0</td>
      <td>0</td>
      <td>0</td>
      <td>0</td>
    </tr>
  </tbody>
</table>

另一个例子 http://codepen.io/gc-nomade/pen/EKQKBe

关于html - <th> 标签内的 CSS 旋转纯文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42472962/

相关文章:

html - 纯 CSS 替换 OL>LI 元素中的句点

css - 如何删除 bootstrap 4 中的选择选项背景?

html - 字段集元素的边框间距

php - 为什么我不能更改根目录?

html - 如何底部对齐 flex 元素内的元素?

javascript - 使用 jquery 确认电子邮件和密码?

html - 带有标题和固定前 3 列的可滚动表格

html - 标题标签内的多个 div

html - 使用 jQuery 更改链接点击上的 Woocommerce 产品数量

javascript - 最后一招 - jQuery Mashable Mega Menu