posts - 0, comments - 77, trackbacks - 0, articles - 356
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          拖動層.兼容(ie ff ns)

          Posted on 2007-11-16 15:53 semovy 閱讀(269) 評論(0)  編輯  收藏 所屬分類: 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>

          主站蜘蛛池模板: 泸水县| 六安市| 开阳县| 濮阳县| 蕲春县| 丹寨县| 东阿县| 富阳市| 且末县| 临邑县| 宝坻区| 江门市| 涞水县| 多伦县| 济南市| 会理县| 黄大仙区| 克什克腾旗| 涿鹿县| 阿拉善右旗| 团风县| 太湖县| 咸丰县| 瑞金市| 穆棱市| 酉阳| 时尚| 沽源县| 海南省| 淳安县| 木里| 肥西县| 怀仁县| 军事| 东海县| 西吉县| 芜湖县| 福鼎市| 奎屯市| 玛纳斯县| 九台市|