沙漠中的魚

          欲上天堂,先下地獄
          posts - 0, comments - 56, trackbacks - 0, articles - 119
            BlogJava :: 首頁 ::  :: 聯(lián)系 :: 聚合  :: 管理

          float在IE和firefox中的使用

          Posted on 2008-05-26 19:09 沙漠中的魚 閱讀(1333) 評論(0)  編輯  收藏 所屬分類: javascript

          在IE和firefox中,對文檔對象DIV標簽的停靠方式不同,如在IE中他就識別float的屬性,但是在firefox中他就需要cssFloat

          firefox下代碼

          var 
          oDiv
          =document.createElement("div"); 
          oDiv.style.width
          ="101";          
          var iDiv1=document.createElement("div");           iDiv1.style.background="#FFEE00"
          iDiv1.style.width
          =50;    iDiv1.style.cssFloat="left";    iDiv1.innerHTML="右邊"
          iDiv1.style.height
          ="20"; oDiv.appendChild(iDiv1);

          var iDiv2=document.createElement("div");
          iDiv2.style.background
          ="#881200";
          iDiv2.style.width
          =50;
          iDiv2.style.cssFloat
          ="left";
          iDiv2.innerHTML
          ="中間邊";
          iDiv2.style.height
          ="20";
          oDiv.appendChild(iDiv2);

          var iDiv3=document.createElement("div");
          iDiv3.style.background
          ="#235500";
          iDiv3.style.width
          =1;
          iDiv3.style.height
          ="20";
          iDiv3.style.cssFloat
          ="left";
          iDiv3.style.overflow
          ="hidden";
          oDiv.appendChild(iDiv3);

          document.getElementById(
          "test").innerHTML=oDiv.innerHTML;

          IE代碼

          var 
          oDiv
          =document.createElement("div");         oDiv.style.width="101";          
          var 
          iDiv1
          =document.createElement("div");           iDiv1.style.background="#FFEE00"
          iDiv1.style.width
          =50;    iDiv1.style.float="left";    iDiv1.innerHTML="右邊"
          iDiv1.style.height
          ="20"; oDiv.appendChild(iDiv1);

          var iDiv2=document.createElement("div");
          iDiv2.style.background
          ="#881200";
          iDiv2.style.width
          =50;
          iDiv2.style.
          float="left";
          iDiv2.innerHTML
          ="中間邊";
          iDiv2.style.height
          ="20";
          oDiv.appendChild(iDiv2);

          var iDiv3=document.createElement("div");
          iDiv3.style.background
          ="#235500";
          iDiv3.style.width
          =1;
          iDiv3.style.height
          ="20";
          iDiv3.style.
          float="left";
          iDiv3.style.overflow
          ="hidden";
          oDiv.appendChild(iDiv3);

          document.getElementById(
          "test").innerHTML=oDiv.innerHTML;
          主站蜘蛛池模板: 吴川市| 肃南| 襄汾县| 酒泉市| 班玛县| 湖南省| 吴江市| 甘肃省| 张北县| 奉新县| 雷波县| 澎湖县| 泰州市| 梓潼县| 和田市| 固原市| 清徐县| 涟水县| 建昌县| 牙克石市| 塔河县| 凌源市| 台中县| 崇信县| 安乡县| 利辛县| 连山| 望城县| 丰台区| 芦山县| 杭锦后旗| 德阳市| 灵丘县| 武城县| 康乐县| 阿巴嘎旗| 瑞昌市| 施甸县| 库尔勒市| 繁峙县| 大田县|