How to rotate text on table with two rowspan using bootstrap - html

ok, i've been trying hours to make my HTML code working for rotating text on my table, but doesnt seem to work.
here is jsfiddle, if anyone is willing to help me, I will appreciate that
https://jsfiddle.net/zmxr9kyh/
here my html code
$(function() {
var header_height = 0;
$('table th span').each(function() {
if ($(this).outerWidth() > header_height) header_height = $(this).outerWidth();
});
$('table th').height(header_height);
});
th {
position: relative;
padding: 10px;
}
th span {
bottom: 0;
display: inline-table;
left: 50%;
position: absolute;
transform: rotate(-90deg);
transform-origin: 0 50% 0;
white-space: pre;
width: 100;
margin-left: auto;
margin-bottom: -110;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="table table-bordered table-hover table-condensed" align="center" border='1'>
<thead>
<tr>
<th style="border-bottom-color:#FFFFFF"> </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 rowspan="2"><span>IDENTITAS MAHASISWA</span>
</th>
<th rowspan="2">
<center>%</center>
</th>
<th rowspan="2"><span>MAHASISWA PT</span>
</th>
<th rowspan="2">
<center>%</center>
</th>
<th rowspan="2"><span>KURIKULUM</span>
</th>
<th rowspan="2">
<center>%</center>
</th>
<th rowspan="2"><span>NILAI</span>
</th>
<th rowspan="2">
<center>%</center>
</th>
<th rowspan="2"><span>AKM</span>
</th>
<th rowspan="2">
<center>%</center>
</th>
<th rowspan="2"><span>DAYA TAMPUNG</span>
</th>
<th rowspan="2">
<center>%</center>
</th>
<th style="border-bottom-color:#FFFFFF"><span>LAPORAN %</span>
</th>
<th colspan="3" align="center">
<center>MHS</center>
</th>
<th style="border-bottom-color:#FFFFFF">
<center>
KELAS KKULIAH
</center>
</th>
<th rowspan="2">
<center>NILAI</center>
</th>
<th rowspan="2">
<center>AKM</center>
</th>
</tr>
<tr align="center">
<th> </th>
<th> </th>
<th>
<center></center>
</th>
<th>
<center>A</center>
</th>
<th>
<center>C</center>
</th>
<th>
<center>N</center>
</th>
<th>
<center></center>
</th>
</tr>
</thead>
</table>

writing-mode is your friend:
th span {
writing-mode: tb-rl;
}
You might have to add vendor prefixes.
Updated JSFiddle
More information
Browser support of writing-mode

Related

How to use width in a table border?

I am trying to implement cellpadding and cellspacing in my forum, but I just can't get the width="100%" to work with it.
Is it possible to set a width while using cellpadding or cellspacing in my CSS?
.categories div.category td tr{
padding: 80px;
width: 500px;
}
echo '
<table class="categories">
<caption>Category: ', $row2['category'], '</caption>
<thead>
<tr>
<td colspan="3">
<th colspan="3"><a href="create_music_sub.php?cat='.$row2['id'].'&admin='.$row2['admin'].'">
Click here to Create Sub Category
</a></th>
</td>
</tr><tr>
<div class="category"><th scope="col">Category</th></div>
<th scope="col">Creator</th>
<th scope="col">Date Created</th>
</tr>
</thead><tbody>';
If what you meant is to set the table's width to 100%, this works.
And as for the code you provided there were mistakes:
When you want to use a th you don't use a td with it.
The div.category should be inside the tr > th not wrapping it.
When you're posting a question please remove the php fragments and provide a working fiddle for us to be able to help you faster.
Please look at the code to see what I did differently. I think the problem was in your html
table{
border:1px solid black;
width: 100%;
}
tr, th, td{
border:1px solid black;
}
td,th{
padding: 10px;
}
/*If you want the last column to be smaller you can change one of them to a certain width*/
.creator{
width:20%;
}
<table class="categories">
<caption>Category: 1</caption>
<thead>
<tr>
<th colspan="3">
Click here to Create Sub Category
</th>
</tr>
<tr>
<th scope="col">
<div class="category">Category</div>
</th>
<th scope="col">Creator</th>
<th scope="col">Date Created</th>
</tr>
<tr>
<th colspan="2" scope="col">
<div class="category">Category</div>
</th>
<th scope="col">Creator</th>
</tr>
</thead>
</table>
<table class="categories">
<caption>Category: 1</caption>
<thead>
<tr>
<th colspan="3">
Click here to Create Sub Category
</th>
</tr>
<tr>
<th scope="col">
<div class="category">Category</div>
</th>
<th scope="col">Creator</th>
<th scope="col">Date Created</th>
</tr>
<tr>
<th colspan="2" scope="col">
<div class="category">Category</div>
</th>
<th scope="col" class="creator">Creator</th>
</tr>
</thead>
</table>

HTML Vertical text on table for bootstrap

How to make Vertical text on table with fixed and long text with bootstrap ?
I have problem with vertical text on table with bootstrap.
I want to know why my code doesn't work and whats is the correct method to make it work.
Here my table looks like
Here my HTML Code :
<table class="table table-bordered table-hover table-condensed" align="center">
<thead>
<tr>
<th style="border-bottom-color:#FFFFFF" > </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 > </th>
<th > </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>
and this is CSS Code that I am using
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;
}
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;
}
<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>
Have a look at the following JSFiddle
https://jsfiddle.net/a9vc12ve/1/
Using CSS white-space Property
white-space: nowrap;

How can automatically wrapped to a new line the text inside an HTML table cell?

I have the following problem in HTML.
I have this table that contains only a thead:
<table border="1" class="table_legenda" width="100%">
<thead>
<tr>
<th width="8.33%">Codice</th>
<th width="2%">Stato</th>
<th width="8.33%">Creazione<</th>
<th width="8.33%">Registrazione</th>
<th width="6.33%">Autore Cr</th>
<th width="6.33%">Autore Con</th>
<th width="6.33%">Autore Acq</th>
<th width="8.33%">Totale Imponibile</th>
<th width="24.66%">Fornitore</th>
<th width="4.33%">RM riserva</th>
<th width="8.33%">Errore</th>
<th width="8.33%">Azione</th>
</tr>
</thead>
</table>
Now, as you can see, every th cell have setted a percentual width and contains a textual value.
My problem is that if the textual value of a cell is longer than the available space of the cell it will be automatically hidden. I want that the text is automatically wrapped to a new line.
How can I do to obtain this behavior?
Tnx
You need to set the table to have a table-layout:fixed and the th elements to be overflow-wrap:break-word
.table_legenda {
table-layout: fixed;
}
.table_legenda th {
overflow-wrap: break-word;
}
<table border="1" class="table_legenda" width="100%">
<thead>
<tr>
<th width="8.33%">Codice</th>
<th width="2%">Stato</th>
<th width="8.33%">Creazione</th>
<th width="8.33%">Registrazione</th>
<th width="6.33%">Autore Cr</th>
<th width="6.33%">Autore Con</th>
<th width="6.33%">Autore Acq</th>
<th width="8.33%">Totale Imponibile</th>
<th width="24.66%">Fornitore</th>
<th width="4.33%">RM riserva</th>
<th width="8.33%">Errore</th>
<th width="8.33%">Azione</th>
</tr>
</thead>
</table>
demo at http://jsfiddle.net/ma4bc7zj/

Fixed thead with horizontal scrolling

Here is the page: http://lim.bz/dlaczegojezus/tabela2.php
All i want is the header stay always on the top when i'm scrolling page down (and also horizonstal).
That's what i'v got now: http://lim.bz/dlaczegojezus/tabela.php but it's not working in IE (v.10) and scrolling is doesnt work.
<table id="tfhover" class="tftable" border="1">
<thead style="width:1923px;">
<tr>
<th colspan="3" width="115px">Data</th>
<th rowspan="2" width="38px">L.p.</th>
<th colspan="3" class="zielony" width="316px">Użytkownik</th>
<th rowspan="2" width="93px">Strona</th>
<th colspan="3" width="247px">Czas</th>
<th colspan="2" width="162px">Położenie</th>
<th colspan="4" class="zielony" width="139px">Wejście</th>
<th rowspan="2" width="71px">System</th>
<th rowspan="2" width="88px">Przeglądarka</th>
<th colspan="5" class="rozowy" width="375px">Dane demograficzne</th>
<th colspan="2" class="zolty" width="245px">Kontakt</th>
</tr>
<tr>
<th width="38px">r.</th>
<th width="22px">m.</th>
<th width="22px">d.</th>
<th class="zielony" width="174px">login</th>
<th class="zielony" width="59px">nieznany</th>
<th class="zielony" width="50px">znany</th>
<th width="64px">wejście</th>
<th width="64px">wyjście</th>
<th width="86px">suma</th>
<th width="70px">długość</th>
<th width="70px">szerokość</th>
<th class="zielony" width="31px">WEB</th>
<th class="zielony" width="17px">FB</th>
<th class="zielony" width="20px">QR</th>
<th class="zielony" width="27px">NFC</th>
<th class="rozowy" width="92px">wyznanie</th>
<th class="rozowy" width="32px">wiek</th>
<th class="rozowy" width="27px">płeć</th>
<th class="rozowy" width="94px">wykształcenie</th>
<th class="rozowy" width="75px">zaludnienie</th>
<th class="zolty" width="39px">typ</th>
<th class="zolty">adres/numer</th>
</tr>
</thead>
<tbody style="width:1923px;">
<tr>
<?php foreach ($sesTab as $k => $ses) {
$time_on_page = ($ses['visit_out'] - $ses['visit_in']) < 0 ? ' - ' : ($ses['visit_out']-$ses['visit_in'] .' sec.' );
echo "
<td width=\"38px\">".date('Y',strtotime($ses['timestamp']))."</td>
<td width=\"22px\">".date('m',strtotime($ses['timestamp']))."</td>
<td width=\"22px\">".date('d',strtotime($ses['timestamp']))."</td>
<td>$k</td>
<td>".$ses['email']."</td>
<td>".$ses['login']."</td>
<td>".$ses['first_name']."</td>
<td>".$ses['filename']."</td>
<td>".date('H:i:s',$ses['visit_in']+3600*7)."</td>
<td>".date('H:i:s',$ses['visit_out']+3600*7)."</td>
<td>".$time_on_page ." </td>
<td>";
if(empty($ses['loc_lng'])) {
echo ' - ';}
else {
$wspol = DECtoDMS($ses['loc_lng']);
echo $wspol['deg']."°".$wspol['min']."'". substr($wspol['sec'],"0","2")."\"";}
echo "</td>
<td>";
if(empty($ses['loc_lat'])){
echo ' - ';}
else{
$wspol = DECtoDMS($ses['loc_lat']);
echo $wspol['deg']."°".$wspol['min']."'". substr($wspol['sec'],"0","2")."\"";}
echo "</td>
<td>x</td>
<td>-</td>
<td>x</td>
<td>-</td>
<td>".$extra_tab[$ses['session_id']]['os']."</td>
<td>".$extra_tab[$ses['session_id']]['browser']."</td>
<td>".$extra_tab[$ses['session_id']]['religion']."</td>
<td>".$extra_tab[$ses['session_id']]['age']."</td>
<td>".$extra_tab[$ses['session_id']]['sex']."</td>
<td>".$extra_tab[$ses['session_id']]['education']."</td>
<td>".$extra_tab[$ses['session_id']]['population']."</td>
<td>email</td>
<td>".$ses['email']."</td>
</tr>";}
?>
</tbody>
</table>
Try using position:fixed; through your CSS on your thead.
you can change
<thead style="width:1923px;">
to
<thead style="width:1923px; position: fixed; top: 0; left: 0;">
also you need to add this css code to the body
<body style="padding-top: 47px;">
where 47px is the height of your fixed row , you can change it .
Hope this will help you

How to position tables in ie 9 using css?

I am using the following code to position table . It displays well in firefox and chrome but the table gets stick on the left edge of the internet explorer 9 but it should be on the right . Can someone suggest some modifications to this code to display it properly in internet explorer ?
Html code :
<table class="tab1">
<thead>
<tr>
<th scope="col" id="Dimension"><strong>DIMENSIONS</strong></th>
<th scope="col" id="Feet"><strong>FEET</strong></th>
</tr>
</thead>
</tbody>
<tr class="disp-Sing-Spc
">
<th class="color1" scope="col">A (Distance Between Signs)</th>
<th class="color1" scope="col" id="A">100</th>
</tr>
<tr class="disp-Sing-Spc
">
<th class="color2" scope="col">B (Distance Between Signs)</th>
<th class="color2" scope="col" id="B">100</th>
</tr>
<tr class="disp-Sing-Spc
">
<th class="color1" scope="col">C (Distance Between Signs)</th>
<th class="color1" scope="col" id="C">100</th>
</tr>
<tr id="disp-Tpr-Len">
<th class="color2" scope="col">L (Taper Length)</th>
<th class="color2" scope="col" id="Tpr-Len">None</th>
</tr>
<tr class="disp-cn-spc
">
<th class="color1" scope="col">Maximum Taper Channelizing Device Spacing</th>
<th class="color1" scope="col" id="max-taper-dv-spcing">None</th>
</tr>
<tr class="disp-cn-spc
">
<th class="color2" scope="col">Suggested Taper Channelizing Device Spacing</th>
<th class="color2" scope="col" id="Sugg-tpr-dev-spcing">None</th>
</tr>
<tr class="disp-cn-spc
">
<th class="color1" scope="col">Maximum Tangent Channelizing Device Spacing</th>
<th class="color1" scope="col" id="Max-Tgt-dev-Spcing">None</th>
</tr>
<tr class="disp-cn-spc
">
<th class="color2" scope="col">Suggested Tangent Channelizing Device Spacing</th>
<th class="color2" scope="col" id="Sugg-Tgt-dev-Spcing">None</th>
</tr>
<tr>
</tbody>
</table>
CSS Code :
.tab1{
border-collapse: collapse;
position: absolute;
right: 2%;
top: 95px;
width: 25%;
background: #EA9949;
}
In my IE9 it looks fine, however without the 2% right margin. You should try to float your div and use fixed values.
.tab1{
border-collapse: collapse;
position: absolute;
right: 30px;
float:right;
top: 95px;
width: 300px;
background: #EA9949;
}
By the way, you should get read of the tables and use divs instead.