jasmine214--love

          只有當你的內心總是充滿快樂、美好的愿望和寧靜時,你才能擁有強壯的體魄和明朗、快樂或者寧靜的面容。
          posts - 731, comments - 60, trackbacks - 0, articles - 0

          讓DIV不換行 & 多div重疊

          Posted on 2010-07-04 22:23 幻海藍夢 閱讀(5279) 評論(0)  編輯  收藏 所屬分類: JS
          原文:http://www.okajax.com/a/200807/0G0N442008.html
          一,單個DIV:
          1.用nobr元素
          <html>
          <head>
          </head>
          <body>
          <div><nobr>不換行不換行<nobr></div>
          </body>
          </html>


          2.用nowrap元素
          Code:
          <html>
          <head>
          </head>
          <body>
          <div nowrap>div不換行div不換行div不換行</div>
          </body>
          </html>


          二,兩個DIV
          1. 用CSS里的float屬性
          <html>
          <head>
          <style type="text/css">
          div#row1 { float: left; color: blue; }
          div#row2 { color: red }
          </style>
          </head>
          <body>
          <div id="row1">第一個div</div>
          <div id="row2">第二個div不換行</div>
          </body>
          </html>


          2. 用CSS里的diplay屬性
          <html>
          <head>
          <title>CSS中的不換行</title>
          <style type="text/css">
          div#row1 { color: blue;display: inline }
          div#row2 { color: red;display: inline }
          </style>
          </head>
          <body>
          <div id="row1">第一個div</div>
          <div id="row2">第二個div不要換行</div>
          </body>
          </html>

          ?多DIV重疊

          1.

          <div id="left_bot_list1" style="height:448px;width:228px;overflow:auto">????
          ????? </div>
          ?? <div id="left_bot_list2" style="VISIBILITY:hidden;POSITION: relative;Top:expression(0-document.getElementById('left_bot_list1').offsetHeight);">
          ??
          ?? </div>??
          ?? <div id="left_bot_list3" style="VISIBILITY:hidden;POSITION: relative;Top:expression(0-document.getElementById('left_bot_list1').offsetHeight-document.getElementById('left_bot_list2').offsetHeight);">
          ???
          ?? </div>

          <script type="text/javascript" language="Javascript">
          function changeDivleft_bot(num){
          if(num == 1){??

          ?? left_bot_list1.style.visibility = "visible";
          ?? left_bot_list2.style.visibility = "hidden";
          ?? left_bot_list3.style.visibility = "hidden";
          }
          if(num == 2){??
          ??
          ?? left_bot_list1.style.visibility = "hidden";
          ?? left_bot_list2.style.visibility = "visible";
          ?? left_bot_list3.style.visibility = "hidden";
          ??
          }
          if(num == 3){
          ?? left_bot_list1.style.visibility = "hidden";
          ?? left_bot_list2.style.visibility = "hidden";
          ?? left_bot_list3.style.visibility = "visible";

          }

          }

          //alert(tree.loaded);
          </script>


          2.

          <div id="left_bot_list1" style="display:inline;height:448px;width:222px;overflow:auto">????
          ????? </div>
          ?? <div id="left_bot_list2" style="display:none;height:448px;width:222px;overflow:auto">
          ???
          ?? </div>??
          ?? <div id="left_bot_list3" style="display:none;height:448px;width:222px;overflow:auto" >
          ?????
          ?? </div>

          <script type="text/javascript" language="Javascript">
          function changeDivleft_bot(num){
          if(num == 1){??
          ??
          ?? left_bot_list1.style.display = 'inline';
          ?? left_bot_list2.style.display = 'none';
          ?? left_bot_list3.style.display = 'none';
          }
          if(num == 2){??
          ??
          ?? left_bot_list1.style.display = 'none';
          ?? left_bot_list2.style.display = 'inline';
          ?? left_bot_list3.style.display = 'none';
          ??
          }
          if(num == 3){
          ?? left_bot_list1.style.display = 'none';
          ?? left_bot_list2.style.display = 'none';
          ?? left_bot_list3.style.display = 'inline';

          }

          }

          </script>

          注意:此寫法有一個問題

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

          若頁面頭部有以上這句話則無法實現滾動條的功能

          主站蜘蛛池模板: 临泽县| 寿宁县| 新建县| 微山县| 台东市| 襄城县| 平乡县| 临安市| 东至县| 芦溪县| 阳高县| 丰镇市| 康保县| 富宁县| 巫溪县| 江山市| 平遥县| 邢台县| 大理市| 武宁县| 科技| 柳州市| 清流县| 共和县| 萝北县| 怀集县| 昌图县| 登封市| 达尔| 柏乡县| 惠东县| 都江堰市| 新民市| 五莲县| 高密市| 临邑县| 南平市| 东台市| 汾阳市| 晋城| 汉阴县|