enter image description herein html i tried lots of th and text-align methods but i m not getting the expected results
I want my heading tag to be displayed like the image
table#tbl {
valign : top;
table-layout:fixed;
word-wrap : break-word;
text-align:right;
}
<table border="2px" style="width:100%;margin-top:8px;" id="tbl">
<tr>
<th width="3%">Sr no.</th>
<th style="text-align:left" width="25%" >Item</th>
<th width="15%">HSN</th>
<th width="5%">Qty</th>
<th width="10%">Rate/ Item</th>
<th width="10%">Discount/ Item</th>
<th width="10%">Taxable Value</th>
<th width="8%">SGST</th>
<th width="8%">CGST</th>
<th width="12%">Total</th>
</tr>
table#tbl {
valign : top;
table-layout:fixed;
word-wrap : break-word;
text-align:right;
}
You need to set the vertical-align on the th elements. You can do that using the descendent selector like this:
table#tbl th {
vertical-align: top;
}
table#tbl{
table-layout: fixed;
word-wrap: break-word;
text-align: right;
}
table#tbl th {
vertical-align: top;
}
<table border="2px" style="width:100%;margin-top:8px;" id="tbl">
<tr>
<th width="3%">Sr no.</th>
<th style="text-align:left" width="25%">Item</th>
<th width="15%">HSN</th>
<th width="5%">Qty</th>
<th width="10%">Rate/ Item</th>
<th width="10%">Discount/ Item</th>
<th width="10%">Taxable Value</th>
<th width="8%">SGST</th>
<th width="8%">CGST</th>
<th width="12%">Total</th>
</tr>
</table>
Related
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>
I have the following basic table:
.tabella-test{
border-collapse: collapse;
}
.tabella-test td, .tabella-test th{
border: 1px solid black;
}
<TABLE class="tabella-test">
<thead>
<tr>
<th colspan="1" rowspan="2">Tree</th>
<th colspan="1" rowspan="2">Short Description</th>
<th colspan="2">Alberto - Group 12/2009</th>
<th colspan="2">Andrea - Group 12/2010</th>
</tr>
<tr>
<th colspan="1" rowspan="1">Value (x1)</th>
<th colspan="1" rowspan="1">%</th>
<th colspan="1" rowspan="1">Value (x1)</th>
<th colspan="1" rowspan="1">%</th>
</tr>
</thead>
<tbody>
<tr>
<td>ciao</td>
<td>test</td>
<td>-165.889.226</td>
<td>-29,6</td>
<td>310.819.176</td>
<td>150,6</td>
</tr>
</tbody>
</TABLE>
I'd like to put black overlapping borders around every td and th cell. I tried with the above CSS,
but in the pdf generated by iText the output is messed up, only some borders overlap. Any hint?
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;
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/
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.