Table对角线的画法

Table对角线的画法

方法一:SVG(Scalable Vector Graphics) 是一种基于XML的开放的矢量图形描述语言。

示例代码:

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<title>table的对角线</title>

</head>

<body topmargin="100px;">

<center>

<table cellpadding="0" cellspacing="0" border="1" style="border-collapse:collapse;width:400px;">

<tbody>

<colgroup><col width="100px;"><col width="100px;"><col width="100px;"><col width="100px;"></colgroup>

<tr height="25px;">

<td height="25px;">

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%">

<line x1="0" y1="0" x2="100%" y2="100%" style="stroke:black;stroke-width:1">&nbsp;</line>

</svg>

</td>

<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr height="25px;"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr height="25px;"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr height="25px;"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

</tbody>

</table>

</center>

</body>

</html>

效果示意图:

方法二:js的几何画线方法

示例代码:

<!DOCTYPE>

<html>

<head>

<meta charset="utf-8">

<title>table的对角线</title>

<script language="javascript">

function aline(x,y,color){//画线方法

document.write("<img border=‘0‘ style=‘position:absolute; left:"+(x+200)+";top:"+(y+200)+";background-color: "+color+"‘ width=1 height=1>")

}

</script>

</head>

<body leftmargin="200" topmargin="200">

<table cellpadding="0" cellspacing="0" border=‘1‘ style="border-collapse:collapse;width:400px;">

<colgroup><col width="100px;"><col width="100px;"><col width="100px;"><col width="100px;"></colgroup>

<tr height="25px;"><td id="td1">&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr height="25px;"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr height="25px;"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr height="25px;"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

</table>

</body>

<script language="javascript">

function line(x1,y1,x2,y2,color){

var temp;

if(x1>x2){

temp=x1;

x1=x2;

x2=temp;

temp=y1;

y1=y2;

y2=temp;

}

for(var i=x1;i<x2;i++){

x = i;

y = (y2- y1) / (x2 - x1) * (x - x1) + y1;

aline(x,y,color);

}

}

line(td1.offsetLeft,td1.offsetTop,td1.offsetLeft+td1.offsetWidth,td1.offsetTop+td1.offsetHeight,‘#000000‘);//获取画线的坐标

//offsetLeft:返回元素的水平偏移位置。offsetTop:返回元素的垂直偏移位置。offsetWidth:返回元素的宽度。offsetHeight:返回元素的高度。

</script>

</html>

2、效果示意图:

方法三:插入自己所需的背景图片

1、 示例代码:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

</head>

<body  style=‘background-image:url("table1.png");background-position: 540px 8px;background-repeat:no-repeat;‘>

<center>

<table cellpadding="0" cellspacing="0" border="1" style="border-collapse:collapse;width:360px;">

<tbody>

<colgroup><col width="80px;"><col width="100px;"><col width="90px;"><col width="90px;"></colgroup>

<tr height="25px;"><td height="25px;" style="border-bottom:hidden;border-top:hidden;border-right:hidden;"></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr height="25px;"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr height="25px;"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr height="25px;"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

</tbody>

</table>

</center>

</body>

</html>

2、 效果示意图:

补充第二种引入背景图片的方法:(建议使用)

<img src="${webapp}/shipCertificate/newcert/images/Diagonal1.gif" style=" position:relative; padding: 0px; border:none; left:0px;top: 0; width: 80px; height: 26px; ">

方法四:vml画对角线

方法五:transform:rotate()画对角线

时间: 2024-08-07 08:35:38

Table对角线的画法的相关文章

问题:table 可否实现对角线;结果:HTML 斜线 表头

<HTML> <HEAD> <TITLE>斜线表头</TITLE>    </HEAD> <script    Language="javascript"> function    a(x,y,color) {document.write("<img    border='0'    style='position:    absolute;    left:    "+(x)+"

用div css模拟表格对角线

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>用div css模拟表格对角线</t

【转载】用div+css模拟表格对角线

本文引用蓝色理想论坛. 首先声明: 这只是探讨一种CSS模拟表格对角线的用法,实际在工作中可能觉得这样做有点小题大作,这不是本主题讨论的重点.如果对此深以为然的朋友,请一笑过之... 有时在插入文档时,要用到表格对角线,常见的作法是用图片的方式来处理,还有就是用vml来画对角线,能不能用html+css方式来实现呢?答案是肯定的,下面我们来摸拟一个表格对角线. 原理: 用边框线来摸拟斜线,我们知道,如果将一个DIV的边框线设置得足够宽并定义了不同的颜色时,其相邻的两条边框线交界处就是斜线.知道了

现在主流网站为什么都用div+css布局而不是用table

由于刚刚接触前端,一直觉得table布局在代码上看起来比div+css更整洁,div+css布局的页面,一堆的<div><div><div>...</div></div></div>看起来都让人犯密集恐惧症,那么为什么现在的主流网站还都乐此不疲呢?为什么div+css反而成了一种主流布局方式呢?一直对此不解.这篇文章好像是解决了我的问题,先摘录过来,以便查阅. 以下内容摘自:http://www.divcss5.com/wenji/w

&lt;table&gt;标签总结(colspan跨列 ,rowspan跨行)

table标签有些内置属性要设置: <table cellpadding="0" cellspacing="0" border="0" summary="各银行的网上银行支付限额总表"> 1.摘要summary的内容是不会在浏览器中显示出来的.它的作用是增加表格的可读性(语义化), 使搜索引擎更好的读懂表格内容,还可以使屏幕阅读器更好的帮助特殊用户读取表格内容. 2.

关于hibernate中提示can not create table ******

最近这两天,一直在搞hibernate,被 其中一个问题困扰了好久.在网上找了好久,一直都没有找到可行的方法,把jdk,jre,tomcat,装了拆,拆了装,可就是搞不好.实在是没有办法,又重新建了一个项目来测试,,从一点一滴开始试.所有的代码全部都手写,,,,可是问题依旧还在. 之所以一直没有找到解决办法,其实是自己的思维一直局限在一处,,,一直在想着hibernate只要把配置文件配置好,它就可以自己在数据库创建表结构,自己增删改查,相当的方便,可是自己 当时成功了,为什么这次却一而再再而三

【R】数据导入读取read.table函数详解,如何读取不规则的数据(fill=T)

函数 read.table 是读取矩形格子状数据最为便利的方式.因为实际可能遇到的情况比较多,所以预设了一些函数.这些函数调用了 read.table 但改变了它的一些默认参数.  注意,read.table 不是一种有效地读大数值矩阵的方法:见下面的 scan 函数. 一些需要考虑到问题是: 编码问题 如果文件中包含非-ASCII字符字段,要确保以正确的编码方式读取.这是在UTF-8的本地系统里面读取Latin-1文件的一个主要问题.此时,可以如下处理 read.table(file("fil

bootstrap table 服务器端分页--ashx+ajax

1.准备静态页面 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title></title> 6 <meta charset="utf-8" /> 7 <link rel="

mysql启动报错:Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist

mysql在首次启动的时候可能会报错:Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist 这时候可以执行脚本 mysql_install_db –user=mysql –ldata=数据存放的路径