比如高度为1的div,背景设为一张黑白间隔的小图片
或者试用 border:1px dashed #000

解决方案 »

  1.   

    <div style="border:1px dashed #000;border-width:1px 0 0 0;height:1px"></div>
      

  2.   

    <div style="border:1px dashed #000;border-width:1px 0 0 0;height:1px"> </div>
    en
      

  3.   

    <div style="border-top:1px dashed #000;height:1px;overflow:hidden"></div>
      

  4.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">
     </HEAD> <BODY>
     <SCRIPT LANGUAGE="JavaScript">
     <!--
    var pen = {
    setPix : function(x, y, color){
    var point = document.createElement("div");
    with(point.style){
    display = "block";
    position = "absolute";
    width = "1px";
    height = "1px";
    left = x + "px";
    top = y + "px";
    background = "#69C";
    overflow = "hidden";
    }
    document.body.appendChild(point);
    },
    drawDash : function(x1, y1, x2, y2, color){
    this.setPix(x1, y1, color);
    if(x1 == x2 && y1 == y2){
    return;
    } var count = 0; var bTag = false;
    var dx = Math.abs(x2 - x1);
    var dy = Math.abs(y2 - y1);

    if(dx < dy){
    bTag = true; t = x1;
    x1 = y1;
    y1 = t;

    t = x2;
    x2 = y2;
    y2 = t; t = dx;
    dx =dy;
    dy = t; } var tx = (x2 - x1) > 0 ? 1 : -1;
    var ty = (y2 - y1) > 0 ? 1 : -1; var curx = x1;
    var cury = y1; var inc1 = 2 * dy;
    var inc2 = 2 * (dy - dx);
    var d = inc1 - dx; while(curx != x2){
    if(d < 0)d += inc1;
    else{
    cury += ty;
    d += inc2;
    }

    if(count % 2 == 0)
    if(bTag) this.setPix(cury, curx);
    else this.setPix(curx,cury); curx += tx;
    count ++;
    }
    }
    }
    window.onload = function(){
    pen.drawDash(10, 10, 410, 310, "#69c"); }
     //-->
     </SCRIPT>
     </BODY>
    </HTML>
    这个是直接在Body里面的
    夜了
    明天在改灵活一些吧
      

  5.   

    你不说明谁会知道,如果是自由绘图,firefox等用canvas,ie用svg或vml
      

  6.   

    http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm借助这个网址,加上适当修改,就完成了!推荐大家看下!
      

  7.   

    lz提供的网站确实不错
    算法思想很好
    这年头缺的就是这个
    什么js啦都是基础滴基础哦----------------------------------------我滴那个画线算法也是(Bresenham - DDA)
    计算机图形学上 C 代码改的