How to make beautiful table on blogger
Here is a tutorial I share some tricks about how to make a beautiful table on your blogger website. Make a beautiful table content with CSS.FIXED TABLE HEADER make it beautiful table on blogger template. so Let's get started tutorial How to make a fixed table header, make it in three staples, html, css, and javascript.
Add Html
Frist you need to add following the showing html code on you template, copy the showing html code script blow given and pest it.<div class="tbl-header">
<table cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>Code</th>
<th>Company</th>
<th>Price</th>
<th>Change</th>
<th>Change %</th>
</tr>
</thead>
</table>
</div>
<div class="tbl-content">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td>AAC</td>
<td>AUSTRALIAN COMPANY </td>
<td>$1.38</td>
<td>+2.01</td>
<td>-0.36%</td>
</tr>
<tr>
<td>AAD</td>
<td>AUSENCO</td>
<td>$2.38</td>
<td>-0.01</td>
<td>-1.36%</td>
</tr>
<tr>
<td>AAX</td>
<td>ADELAIDE</td>
<td>$3.22</td>
<td>+0.01</td>
<td>+1.36%</td>
</tr>
<tr>
<td>XXD</td>
<td>ADITYA BIRLA</td>
<td>$1.02</td>
<td>-1.01</td>
<td>+2.36%</td>
</tr>
<tr>
<td>AAC</td>
<td>AUSTRALIAN COMPANY </td>
<td>$1.38</td>
<td>+2.01</td>
<td>-0.36%</td>
</tr>
<tr>
<td>AAD</td>
<td>AUSENCO</td>
<td>$2.38</td>
<td>-0.01</td>
<td>-1.36%</td>
</tr>
<tr>
<td>AAX</td>
<td>ADELAIDE</td>
<td>$3.22</td>
<td>+0.01</td>
<td>+1.36%</td>
</tr>
<tr>
<td>XXD</td>
<td>ADITYA BIRLA</td>
<td>$1.02</td>
<td>-1.01</td>
<td>+2.36%</td>
</tr>
<tr>
<td>AAC</td>
<td>AUSTRALIAN COMPANY </td>
<td>$1.38</td>
<td>+2.01</td>
<td>-0.36%</td>
</tr>
<tr>
<td>AAD</td>
<td>AUSENCO</td>
<td>$2.38</td>
<td>-0.01</td>
<td>-1.36%</td>
</tr>
<tr>
<td>AAX</td>
<td>ADELAIDE</td>
<td>$3.22</td>
<td>+0.01</td>
<td>+1.36%</td>
</tr>
<tr>
<td>XXD</td>
<td>ADITYA BIRLA</td>
<td>$1.02</td>
<td>-1.01</td>
<td>+2.36%</td>
</tr>
<tr>
<td>AAC</td>
<td>AUSTRALIAN COMPANY </td>
<td>$1.38</td>
<td>+2.01</td>
<td>-0.36%</td>
</tr>
<tr>
<td>AAD</td>
<td>AUSENCO</td>
<td>$2.38</td>
<td>-0.01</td>
<td>-1.36%</td>
</tr>
<tr>
<td>AAX</td>
<td>ADELAIDE</td>
<td>$3.22</td>
<td>+0.01</td>
<td>+1.36%</td>
</tr>
<tr>
<td>XXD</td>
<td>ADITYA BIRLA</td>
<td>$1.02</td>
<td>-1.01</td>
<td>+2.36%</td>
</tr>
<tr>
<td>AAC</td>
<td>AUSTRALIAN COMPANY </td>
<td>$1.38</td>
<td>+2.01</td>
<td>-0.36%</td>
</tr>
<tr>
<td>AAD</td>
<td>AUSENCO</td>
<td>$2.38</td>
<td>-0.01</td>
<td>-1.36%</td>
</tr>
<tr>
<td>AAX</td>
<td>ADELAIDE</td>
<td>$3.22</td>
<td>+0.01</td>
<td>+1.36%</td>
</tr>
<tr>
<td>XXD</td>
<td>ADITYA BIRLA</td>
<td>$1.02</td>
<td>-1.01</td>
<td>+2.36%</td>
</tr>
<tr>
<td>AAC</td>
<td>AUSTRALIAN COMPANY </td>
<td>$1.38</td>
<td>+2.01</td>
<td>-0.36%</td>
</tr>
<tr>
<td>AAD</td>
<td>AUSENCO</td>
<td>$2.38</td>
<td>-0.01</td>
<td>-1.36%</td>
</tr>
<tr>
<td>AAX</td>
<td>ADELAIDE</td>
<td>$3.22</td>
<td>+0.01</td>
<td>+1.36%</td>
</tr>
<tr>
<td>XXD</td>
<td>ADITYA BIRLA</td>
<td>$1.02</td>
<td>-1.01</td>
<td>+2.36%</td>
</tr>
<tr>
<td>AAC</td>
<td>AUSTRALIAN COMPANY </td>
<td>$1.38</td>
<td>+2.01</td>
<td>-0.36%</td>
</tr>
<tr>
<td>AAD</td>
<td>AUSENCO</td>
<td>$2.38</td>
<td>-0.01</td>
<td>-1.36%</td>
</tr>
<tr>
<td>AAX</td>
<td>ADELAIDE</td>
<td>$3.22</td>
<td>+0.01</td>
<td>+1.36%</td>
</tr>
<tr>
<td>XXD</td>
<td>ADITYA BIRLA</td>
<td>$1.02</td>
<td>-1.01</td>
<td>+2.36%</td>
</tr>
<tr>
<td>AAC</td>
<td>AUSTRALIAN COMPANY </td>
<td>$1.38</td>
<td>+2.01</td>
<td>-0.36%</td>
</tr>
<tr>
<td>AAD</td>
<td>AUSENCO</td>
<td>$2.38</td>
<td>-0.01</td>
<td>-1.36%</td>
</tr>
<tr>
<td>AAX</td>
<td>ADELAIDE</td>
<td>$3.22</td>
<td>+0.01</td>
<td>+1.36%</td>
</tr>
<tr>
<td>XXD</td>
<td>ADITYA BIRLA</td>
<td>$1.02</td>
<td>-1.01</td>
<td>+2.36%</td>
</tr>
</tbody>
</table>
</div>
Add CSS
Add following the css code script on the blow given, edit your template and add following code.<style type='text/css'>
table{width:100%;table-layout:fixed}.tbl-header{background-color:rgba(255,255,255,.3)}.tbl-content{height:300px;overflow-x:auto;margin-top:0;border:1px solid rgba(255,255,255,.3)}th{padding:20px 15px;text-align:left;font-weight:500;font-size:12px;color:#fff;text-transform:uppercase}td{padding:15px;text-align:left;vertical-align:middle;font-weight:300;font-size:12px;color:#fff;border-bottom:solid 1px rgba(255,255,255,.1)}
</style>
Add Javascript '.tbl-content' consumed little space for vertical scrollbar, scrollbar width depend on browser/os/platfrom. Here calculate the scollbar width.
<script style='text/javascript'>
//<![CDATA[
$(window).on("load resize ", function() {
var scrollWidth = $('.tbl-content').width() - $('.tbl-content table').width();
$('.tbl-header').css({'padding-right':scrollWidth});
}).resize();
//]]>
</script>
And Done, Your fixed table header is complete. Click on the showing links blow given for see Demo.
Thank you.
Test...test
ReplyDeletePost a Comment