Table can not scroll on IOS device? - html

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>

Related

Center <th> in bootstrap in double header table

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

How to implement sort Table according to a single column in Angular 6 (using boostrap)

Can anyone please suggest the best way to implement sorting in angular 6 using botstrap. This is my table.
I need to sort the table using mrp , ssp ,ymp .
I tried to search for tutorials , but there is angularjs implementation all over the internet .
Can anyone suggest a proper angular 6 implemetation using data table
<table id="myTable" class="table table-striped table-bordered table-dark" #myTable>
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Id</th>
<th scope="col">Image</th>
<th scope="col">Name</th>
<th scope="col">Seller</th>
<th scope="col">Category</th>
<th scope="col">Status</th>
<th scope="col" sortable="mrp.value" class="sortable">MRP
</th>
<th scope="col" class="sortable">SSP
</th>
<th scope="col" class="sortable" >YMP
</th>
<th scope="col" class="sortable">Date Added
</th>
</tr>
</thead>
<tbody *ngFor ="let tempProduct of products">
<tr>
<th scope="row"><input type="checkbox" name="cbProducts"
value=`${{tempProduct.id}}`></th>
<td>{{tempProduct.id}}</td>
<td>
<img
src="http://localhost:8080/YourMart-PMP-Admin-
Panel/resources/images/{{tempProduct.primaryImg}}"
height="50" width="50">
</td>
<td>{{tempProduct.name}}</td>
<td>{{tempProduct.seller.name}}</td>
<td>{{tempProduct.category.name}}</td>
<td>{{tempProduct.status}}</td>
<td >{{tempProduct.mrp}}</td>
<td >{{tempProduct.ssp}}</td>
<td >{{tempProduct.ymp}}</td>
<td >{{tempProduct.created}}</td>
</tr>
</tbody>
</table>

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>

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/

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.