posts - 0, comments - 77, trackbacks - 0, articles - 356
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          拖動(dòng)層.兼容(ie ff ns)

          Posted on 2007-11-16 15:53 semovy 閱讀(263) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): CSS式樣

          <html>
          <head>
          <style type="text/css">
          <!--
          #headline{
           width:100px;
           height:20px;
           background-color:#eee;
           border:1px solid #333;
           position:relative;
           top:0px;
           text-align:center;
           cursor:move;
           }
          #layer{
           width:100px;
           height:100px;
           background-color:#eee;
           border:1px solid #fff;
           position:absolute;
           top:30px;
           left:200px;
                 
           text-align:center;
           cursor:default;  

          }
          .content
          {
           width:100px;
           height:100%;
           position:relative;
                  font-size:20px;
                  color:green;
          }
          //-->
          </style>
          <script language="javascript">
          <!--//
          function drag(head,layer){
           head.onmousedown=function(a){
            var d=document;if(!a)a=window.event;
            var x=a.layerX?a.layerX:a.offsetX,y=a.layerY?a.layerY:a.offsetY;
            if(head.setCapture)
             head.setCapture();
            else if(window.captureEvents)
             window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);

            d.onmousemove=function(a){
             if(!a)a=window.event;
             if(!a.pageX)a.pageX=a.clientX;
             if(!a.pageY)a.pageY=a.clientY;
             var tx=a.pageX-x,ty=a.pageY-y;
             //o.style.left=tx;
             //o.style.top=ty;
             layer.style.left=tx;
             layer.style.top=ty;
            };

            d.onmouseup=function(){
             if(head.releaseCapture)
              head.releaseCapture();
             else if(window.captureEvents)
              window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
             d.onmousemove=null;
             d.onmouseup=null;
            };
           };
          }
          window.onload=function(){
           drag(document.getElementById('headline'),document.getElementById('layer'));
          };
          //-->
          </script>
          </head>
          <body>

          <div id="layer" >
           <div id='headline' algin="center">headling</div>
           <div id="content">
            <table class="content"><tbody><tr><td>absoluteabsoluteabsoluteabsoluteabsolute</td></tr></tbody></table>
           </div> 
           

          </div>

          </body>
          </html>

          主站蜘蛛池模板: 东丰县| 新乡县| 汕尾市| 长治市| 临城县| 枣强县| 烟台市| 驻马店市| 南岸区| 东源县| 日照市| 广丰县| 抚州市| 湾仔区| 稻城县| 沛县| 白河县| 咸阳市| 石城县| 拜城县| 遂溪县| 包头市| 浦北县| 沽源县| 南平市| 思茅市| 宽甸| 多伦县| 南昌市| 泌阳县| 汕头市| 勐海县| 康乐县| 伽师县| 囊谦县| 上林县| 松滋市| 呼玛县| 仁布县| 腾冲县| 云浮市|