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>

          主站蜘蛛池模板: 维西| 林芝县| 成安县| 夏津县| 宁乡县| 怀集县| 石台县| 谢通门县| 平谷区| 贺州市| 文安县| 安义县| 桂平市| 灵宝市| 蒙阴县| 越西县| 梁河县| 峨眉山市| 东方市| 宁德市| 灵寿县| 临洮县| 安化县| 平山县| 广安市| 潜山县| 塘沽区| 安陆市| 阿坝| 鄢陵县| 榆林市| 庐江县| 清镇市| 怀安县| 清远市| 凉山| 文化| 祁连县| 伊宁县| 图们市| 奉化市|