JSP表格画斜线

表格画斜线

缺点是:浏览器自带打印会出现格式错乱,页面展示没问题

 <script type="text/javascript">
 	$(function () {
        	 window.onload=function(){
             	setTimeout( function(){
             	// 开始时定时器延迟加载  DOM树加载完成后再进行画斜线
             		 change()
             		}, 500 );
             }
        });
        function change() {
   			// 初始值
            var top = 0;
            var left = 0;
            var length = 0;
            var angle = 0; // 旋转角度
            var width = $('.inslash').width(); // 宽度
            var height = $('.inslash').height(); // 高度
            //线条position设置为absolute时,坐标需要重新定位,获取单元格的偏移量作为线条的偏移量
            top = $('.inslash').offset().top; // 距离顶部表格得高度
            left = $('.inslash').offset().left + width; // 距离左边表格得距离
            if(height>0){
            	angle = Math.round(Math.atan(width / height) * 180 / Math.PI);
            	 //获取对角线角度,Math.atan()获取的是弧度,乘于180/pi得到角度
            }
            length = Math.sqrt(width * width + height * height); //获取对角线长度,勾股定理
            $('style').append('.inslash::before {content: ""; position: absolute; width: 1px;left: ' + left + 'px;top: ' + top + 'px;background-color: #000; transform-origin: top;height: ' + length + 'px; transform: rotate(' + angle + 'deg);}');
        }; 
        
 </script>
 	<table>
		 <tr align="center">
            <td >
                <div align="center">测量</div>
            </td>
            
            <td colspan="2">
              <select id="input132" style="width: 95%;">
                    <option>全部</option>
              </select>
            </td>
            <td colspan="2">
               <select id="input133" style="width: 95%;">
                  <option>全部</option>
                </select>
            </td>
            <td colspan="2">
                <select id="input134" style="width: 95%;">
                  <option>全部</option>
                </select>
            </td>
             <td colspan="2">
               <select id="input135" style="width: 95%;">
                  <option>全部</option>
                </select>
            </td>
             <td colspan="2">
               <select id="input136" style="width: 95%;">
                  <option>全部</option>
                </select>
            </td>
             <td colspan="2">
              <select id="input137" style="width: 95%;">
                   <option>全部</option>
                </select>
            </td>
           
            <td class="inslash" >
               
            </td>
          </tr>
        </table>
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值