沙漠中的魚

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

          float在IE和firefox中的使用

          Posted on 2008-05-26 19:09 沙漠中的魚 閱讀(1337) 評論(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;
          主站蜘蛛池模板: 汕头市| 苗栗市| 绿春县| 邳州市| 鄂尔多斯市| 台北县| 郸城县| 巫山县| 长阳| 宜章县| 宜宾县| 惠州市| 正宁县| 固安县| 花莲市| 北宁市| 平顺县| 泽库县| 沐川县| 梁山县| 望江县| 涿州市| 贡嘎县| 绥宁县| 陈巴尔虎旗| 海晏县| 黔江区| 江陵县| 甘肃省| 松阳县| 安多县| 临西县| 平阴县| 谢通门县| 涡阳县| 象州县| 板桥市| 潞城市| 南京市| 定南县| 威远县|