HTML桌上的垂直文本为bootstrap

时间:2016-10-07 08:35:04

标签: html css twitter-bootstrap

如何使用bootstrap在固定文本和长文本的表格上制作垂直文本? 我在带有引导程序的表上有垂直文本的问题。 我想知道为什么我的代码不起作用,什么是使其正常工作的正确方法。

这里我的表看起来像

enter image description here

这是我的HTML代码:

<table class="table table-bordered table-hover table-condensed" align="center">
                <thead>
                    <tr>
                        <th style="border-bottom-color:#FFFFFF" >&nbsp;</th>

<th style="border-bottom-color:#FFFFFF">

              </th>
               <th colspan="12" align="center">
                <center>  VALIDASI </center>
              </th>
                        <th style="border-bottom-color:#FFFFFF"><center></center></th>
                        <th colspan="6" align="center">
                            <center>JUMLAH  RECORD</center>             </th>
                    </tr>
                    <tr align="center">
                      <th  style="border-bottom-color:#FFFFFF">NO.</th>
                      <th  style="border-bottom-color:#FFFFFF" >PROGRAM STUDI</th>
                      <th class="vertical" rowspan="2"><div class="vertical">IDENTITAS MAHASISWA</div></th>
                      <th  rowspan="2"><center>%</center></th>
                      <th  rowspan="2"><center>MAHASISWA PT</center></th>
                      <th  rowspan="2"><center>%</center></th>
                      <th  rowspan="2"><center>KURIKULUM</center></th>
                      <th  rowspan="2"><center>%</center></th>
                      <th  rowspan="2"><center>NILAI</center></th>
                      <th rowspan="2"><center>%</center></th>
                      <th  rowspan="2"><center>AKM</center></th>
                      <th  rowspan="2"><center>%</center></th>
                      <th  rowspan="2"><center>DAYA TAMPUNG</center></th>
                      <th  rowspan="2"><center>%</center></th>
                      <th  style="border-bottom-color:#FFFFFF">LAPORAN</th>
                      <th colspan="3" align="center"><center>MHS</center></th>
                      <th  style="border-bottom-color:#FFFFFF"><center>
                        KELAS 
                      </center></th>
                      <th  rowspan="2"><center>NILAI</center></th>
                      <th  rowspan="2"><center>AKM</center></th>
                  </tr>
                    <tr align="center">
                      <th >&nbsp;</th>
                      <th  >&nbsp;</th>
                      <th ><center>%</center></th>
                      <th ><center>A</center></th>
                      <th ><center>C</center></th>
                      <th ><center>N</center></th>
                      <th ><center>KULIAH</center></th>
                  </tr>
                </thead>

这是我正在使用的CSS代码

div.vertical
{
 margin-left: -85px;
 position: absolute;
 width: auto;
 transform: rotate(-90deg);
 -webkit-transform: rotate(-90deg); /* Safari/Chrome */
 -moz-transform: rotate(-90deg); /* Firefox */
 -o-transform: rotate(-90deg); /* Opera */
 -ms-transform: rotate(-90deg); /* IE 9 */
}

th.vertical
{
 height: 150px;
 line-height: 14px;
 padding-bottom: 20px;
 text-align: left;

}

2 个答案:

答案 0 :(得分:3)

&#13;
&#13;
table {
  border:1px solid black;
}
table th {
  border-bottom:1px solid black;
}


th.rotate {
  height:80px;
  white-space: nowrap;
  position:relative;
}

th.rotate > div {
  transform: rotate(90deg);
  position:absolute;
  left:0;
  right:0;
  top: 10px;
  margin:auto;
  
}
&#13;
<table>
  <tr>
    <th class="rotate">
      <div><span>Column 1</span></div>
    </th>
    <th class="rotate">
      <div><span>Column 2</span></div>
    </th>
    <th class="rotate">
      <div><span>Column 3</span></div>
    </th>
  </tr>
  <tr>
    <td>col</td>
    <td>col</td>
    <td>col</td>
  </tr>
</table>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

看看下面的JSFiddle

https://jsfiddle.net/a9vc12ve/1/

使用CSS空白属性

 white-space: nowrap;