栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在具有自动高度/没有文本溢出的表格标题中显示垂直文本?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在具有自动高度/没有文本溢出的表格标题中显示垂直文本?

如果您使用伪元素和垂直填充,则基本上可以画一个
方形框或

<td>
:

.verticalTableHeader {    text-align:center;    white-space:nowrap;    transform-origin:50% 50%;    transform: rotate(90deg);}.verticalTableHeader:before {    content:'';    padding-top:110%;    display:inline-block;    vertical-align:middle;}

If you want to keep

<td>
ith a small width,
table-layout:fixed
+
width

might help. http://jsfiddle.net/qjzwG/320/

.verticalTableHeader {    text-align:center;    white-space:nowrap;    transform: rotate(90deg);}.verticalTableHeader p {    margin:0 -100% ;    display:inline-block;}.verticalTableHeader p:before{    content:'';    width:0;    padding-top:110%;    display:inline-block;    vertical-align:middle;}table {    text-align:center;    table-layout : fixed;    width:150px}

If you want table to still be able to grow from it’s content but not from
width of

<th>
, using a wrapper with a hudge negative margin opposite to
dir/direction of document might do : apparently, the closest to your needs
, http://jsfiddle.net/qjzwG/320/

<table border="1">    <tr>      <th ><p>First</p></th>      <th ><p>Second-long-header</p></th>      <th ><p>Third</p></th>    </tr>.verticalTableHeader {    text-align:center;    white-space:nowrap;    transform: rotate(90deg);}.verticalTableHeader p {    margin:0 -999px;    display:inline-block;}.verticalTableHeader p:before {    content:'';    width:0;    padding-top:110%;        display:inline-block;    vertical-align:middle;}table {    text-align:center;}

来自演示和基础的HTML:

<table border="1">    <tr>      <th >First</th>      <th >Second</th>      <th >Third</th>    </tr>    <tr>      <td>foo</td>      <td>foo</td>      <td>foo</td>    </tr>    <tr>      <td>foo</td>      <td>foo</td>      <td>foo</td>    </tr>    <tr>      <td>foo</td>      <td>foo</td>      <td>foo</td>    </tr></table>

对于较旧的IE,您需要使用书写模式(CSS)



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/635425.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号