沙漠中的魚

          欲上天堂,先下地獄
          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標(biāo)簽的停靠方式不同,如在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;
          主站蜘蛛池模板: 金寨县| 石景山区| 菏泽市| 石泉县| 上饶市| 尼木县| 舟山市| 马尔康县| 安新县| 乌拉特前旗| 合山市| 德令哈市| 华安县| 自贡市| 龙川县| 隆回县| 宜宾县| 桂阳县| 永兴县| 莱芜市| 宣武区| 科尔| 双桥区| 永康市| 西盟| 禄丰县| 化德县| 奉节县| 朔州市| 芒康县| 武安市| 来凤县| 岗巴县| 江西省| 龙门县| 曲水县| 哈密市| 临漳县| 通化市| 涟水县| 涿州市|