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.
Related
I am currently working on a html table, and this is what I have so far:
<table class='table' id="intern_table" style='display: block; overflow-x: auto; white-space: nowrap;' >
<thead>
<tr id="intern_table_title" style="color: black">
<th scope="col" class='text-center'>Industry Category</th>
<th scope="col" class='text-center'>Name</th>
<th scope="col" class='text-center'>Job Category</th>
<th scope="col" class='text-center'>Job Name</th>
<th scope="col" class='text-center'>Job Location</th>
<th scope="col" class='text-center'>Deadline</th>
<th scope="col" class='text-center'>hits</th>
</tr>
</thead>
<tbody>
....
</tbody>
</table>
Since I'd like to make elements in the table not to change line, which means if overflow occurs, I'd like to make it scrollable, so I added this to the table element:
<style='display: block; overflow-x: auto; white-space: nowrap;'>
It successfully works on every different device except IOS system. Also, I've tried modifying the overflow-x: auto to overflow-x:touch, but still, the table wasn't scrollable on IOS device. Any ideas about how to solve this problem? Thanks in advance.
Please add the below CSS and check if it works
<style>
table
{
overflow-x: scroll;
}
</style>
Useful links: https://community.grafana.com/t/grafana-5-overflow-scroll-doest-work-on-mobile/5480/5
Use both overflow: scroll and -webkit-overflow-scrolling: touch for iOS-Safari.
table {
white-space: nowrap;
overflow: scroll;
-webkit-overflow-scrolling: touch
}
<table class='table' id="intern_table">
<thead>
<tr id="intern_table_title" style="color: black">
<th scope="col" class='text-center'>Industry Category</th>
<th scope="col" class='text-center'>Name</th>
<th scope="col" class='text-center'>Job Category</th>
<th scope="col" class='text-center'>Job Name</th>
<th scope="col" class='text-center'>Job Location</th>
<th scope="col" class='text-center'>Deadline</th>
<th scope="col" class='text-center'>hits</th>
</tr>
</thead>
<tbody>
<tr><td colspan="7">...</td></tr>
</tbody>
</table>
It's an old post but i was struggling with this and found a solution, i had the same problem, in desktop and browser mobile view, everything was working fine, but in the iphone even in safari and chrome the table came out of the container, but the solution was much simpler than i thought
Just wrap the table in a div with overflow-x: auto, in your case:
<div style="overflow-x:auto;">
<table class='table' id="intern_table">
<thead>
<tr id="intern_table_title" style="color: black">
<th scope="col" class='text-center'>Industry Category</th>
<th scope="col" class='text-center'>Name</th>
<th scope="col" class='text-center'>Job Category</th>
<th scope="col" class='text-center'>Job Name</th>
<th scope="col" class='text-center'>Job Location</th>
<th scope="col" class='text-center'>Deadline</th>
<th scope="col" class='text-center'>hits</th>
</tr>
</thead>
<tbody>
<tr><td colspan="7">...</td></tr>
</tbody>
</table>
</div>
Hello i have a table and i want to center a th between two other th.
I want to change the position of th Vieillesse de base to be displayed in the center of Provisionnel and Régularisation.
Here my HTML :
<div class="row mt-1">
<div class="col-12">
<table class="table table-striped table-adjust ">
<thead class="cordonnes-cabinet">
<tr>
<th scope="col">Date</th>
<th scope="col" style="text-align:center" colspan="2">Vieillesse de base</th>
<th scope="col" style="text-align:right">Complémentaire</th>
<th scope="col" style="text-align:right">Total</th>
</tr>
<tr>
<th scope="col">...</th>
<th scope="col" style="text-align:right">Provisionnel</th>
<th scope="col" style="text-align:right">Régularisation</th>
<th scope="col" style="text-align:right">...</th>
<th scope="col" style="text-align:right">...</th>
</tr>
</thead>
<tbody class="cordonnes-cabinet">
#for (int i = 0; i < echeancierGeneriqueAjustee.Count; i++)
{
<tr>
<th style="font-weight:100">#(echeancierGeneriqueAjustee[i]["Date"])</th>
<td style="text-align:right">#(echeancierGeneriqueAjustee[i]["MontantProv"])</td>
<td style="text-align:right">#(echeancierGeneriqueAjustee[i]["MontantRegul"])</td>
<td style="text-align:right">#(echeancierGeneriqueAjustee[i]["MontantComplement"])</td>
<td style="text-align:right">#(echeancierGeneriqueAjustee[i]["TotalEcheance"])</td>
</tr>
}
<tr>
<th style="font-size:14px">Total</th>
<td style="text-align:right">#(echeancierGeneriqueAjustee[0]["TotalProv"])</td>
<td style="text-align:right">#(echeancierGeneriqueAjustee[0]["TotalRegul"])</td>
<td style="text-align:right">#(echeancierGeneriqueAjustee[0]["TotalComplement"])</td>
<td style="text-align:right">#(echeancierGeneriqueAjustee[0]["Total"])</td>
</tr>
</tbody>
</table>
</div>
</div>
The key to do this is use html colspan in the th, to simulate equality of width with the second row. Then you only need to use .text-center.
In you particular case, use colspan="2" in the second th
JS FIDDLE DEMO
<table class="table">
<thead class="cordonnes-cabinet">
<tr>
<th>Date</th>
<th colspan="2" class="text-center">Vieillesse de base</th>
<th>Complémentaire</th>
<th>Total</th>
</tr>
<tr>
<th style="width:10%">...</th>
<th class="text-center">Provisionnel</th>
<th class="text-center">Régularisation</th>
<th>...</th>
<th>...</th>
</tr>
</thead>
<tbbody>
<tr>
<th>col1</th>
<td class="text-center">col2</td>
<td class="text-center">col3</td>
<td>col4</td>
<td>col5</td>
</tr>
</tbbody>
</table>
So the issue here is that your text is centered but the Column to the right is X wide and creates a optical illusion that your column is a lot wider.
I would set the column saying "Complémentaire" to text-align: left with class text-left then it will create the illuion you want.
Ive attached a picture where you can see that your code actually centers the text its just an optical illuion
This is how it would look with left aligned in the blue column:
And now its just a question on how to make it pretier with paddings on the td's and th's
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>
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
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