這是我同事今天問我的一個問題
我從來沒有想過在html裡頭,那根斜線怎麼畫
以為用dreamwave或者是用word存成html就可以了
沒想到居然也是個需要控制的東西呀..(茶)
底下的範例是畫出那根斜線的範例

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>表格裡的斜線,類似課程表的斜線</title>
</head>
<script Language="javascript">
function a(x,y,color)
{document.write("<img border='0' style='position: absolute; left: "+(x+20)+"; top: "+(y+20)+";background-color: "+color+"' src='px.gif' width=1 height=1>")}
</script>

<body leftmargin=20 topmargin=20>
<TABLE border=0 bgcolor="000000" cellspacing="1" width=400>
<TR bgcolor="FFFFFF">
    <TD id="td1"> </TD>
    <TD>張三</TD>
    <TD>李四</TD>
    <TD>王五</TD>
</TR>
<TR bgcolor="FFFFFF">
    <TD>數學</TD>
    <TD>55</TD>
    <TD>66</TD>
    <TD>77</TD>
</TR>
<TR bgcolor="FFFFFF">
    <TD>英語</TD>
    <TD>99</TD>
    <TD>68</TD>
    <TD>71</TD>
</TR>
<TR bgcolor="FFFFFF">
    <TD>語文</TD>
    <TD>33</TD>
    <TD>44</TD>
    <TD>55</TD>
</TR>
</TABLE>
<script>
function line(x1,y1,x2,y2,color)
{
    var tmp
    if(x1>=x2)
    {
        tmp=x1;
        x1=x2;
        x2=tmp;
        tmp=y1;
        y1=y2;
        y2=tmp;
    }
    for(var i=x1;i<=x2;i++)
    {
        x = i;
        y = (y2 - y1) / (x2 - x1) * (x - x1) + y1;
        a(x,y,color);
    }
}
//line(1,1,100,100,"000000");
line(td1.offsetLeft,td1.offsetTop,td1.offsetLeft+td1.offsetWidth,td1.offsetTop+td1.offsetHeight,'#000000')
</script>
</BODY>
</html>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 teall 的頭像
    teall

    等一個晴天

    teall 發表在 痞客邦 留言(0) 人氣()