用JS和HTML实现斜线表头

1 篇文章 0 订阅

首先下载JS图形库API:wz_jsgraphics.js
第二步:编写html文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html>  
    <head>  
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>                    
      <title>Javascript table example.</title>  
      <script type="text/javascript" src="wz_jsgraphics.js"></script>  
      <style> 
        body{font-family:'微软雅黑';font-size:12px;color:white;}
        .box{width:300px;height:500px;margin:10px auto;}
        #table {  
            margin: 0px;   
            padding:0px;   
            border-collapse: collapse;  
            table-layout:fixed; 
            border:solid 1px white;   
        }  
        thead tr td{background:rgb(99,168,235);height:20px;}
        tbody tr td{color:#000;}
        .table_td {  
            border: solid 1px #e4e4e4;
            width:80px;
            text-align: center;  
            height:40px;
            line-height:40px;
        }  
    </style>  
    </head>  
<body>  
    <!-- 定义绘制图形的区域,调用jsGraphics提供的对象及相关的方法以完成斜线的绘制-->
    <div id="Canvas" style="position:relative;height:5px;width:5px;"></div>  
    <script type="text/javascript">  
        var jg = new jsGraphics("Canvas");    
        jg.setColor("white");  
        jg.drawLine(524, 15, 600, 55); 
        jg.drawLine(524, 15, 740, 55);
        jg.paint();  
    </script>   
        <div class="box">
        <table id="table">  
            <thead>  
                    <tr>  
                        <td style="padding-top:20px;width:70px;">人名</td>  
                        <td style="padding-top:22px;width:80px;">卡号</td> 
                        <td style="padding-bottom:18px;width:70px;">指标</td> 
                        <td class="table_td">信用卡支出</td>  
                    </tr>  
                </thead>  
            <tbody>   
                <tr>  
                    <td class="table_td">1</td>  
                    <td colspan="2" class="table_td">理论</td>  
                    <td class="table_td">实践</td>  
                </tr>                         
                <tr>  
                    <td class="table_td">3</td>  
                    <td colspan="2" class="table_td">实践</td>  
                    <td class="table_td">理论</td>  
                </tr>   
            </tbody>  
        </table> 
        </div>
      </body>  
    </html>  

效果图:
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值