<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    我是FE,也是Fe

    前端來源于不斷的點(diǎn)滴積累。我一直在努力。

    統(tǒng)計(jì)

    留言簿(15)

    閱讀排行榜

    評論排行榜

    使用div模擬出frameset效果

    在史前時(shí)代,大家喜歡用frameset來做框架結(jié)構(gòu)?;叵肫饋韋rameset的優(yōu)點(diǎn)在于布局的自適應(yīng)。frameset已經(jīng)早不是web標(biāo)準(zhǔn)推薦的了。而且弄這么多頁面去實(shí)現(xiàn)這個(gè)效果也很蹩腳。其實(shí)可以用css布局和定位來實(shí)現(xiàn)這樣的效果的。下面是一個(gè)demo:
    <!doctype html> 
        
    <html xmlns="http://www.w3.org/1999/xhtml" >
         
    <head>
          
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          
    <title>div仿框架布局</title>
          
    <style type="text/css">
           * 
    { margin:0; padding:0; list-style:none;}
           html,body 
    { height:100%; overflow:hidden;}
           
    /*reset panel posotion*/
           .panel
    {position:absolute;top:0px;right:0px;bottom:0px; left:0px; z-index:1;}
           .top 
    { height:50px; background-color:#ccc;}
           .left 
    { top:50px; bottom:50px; width:200px; background-color:#eee;}
           .main 
    { left:200px; top:50px; bottom:50px;background-color:#f5f5f5;}
           .bottom 
    { top:auto;  height:50px;background-color:#ccc;}
           .panel iframe 
    { width:100%; height:100%;}

            
    /* class for hide top*/
           .hidetop .top
    {display:none;}
           .hidetop .left,.hidetop .main
    {top:0px;}

            
    /* class for hide bottom*/
           .hidebottom .bottom
    {display:none;}
           .hidebottom .left,.hidebottom .main
    {bottom:0px;}

           
    /*class for hide left*/
           .hideleft .left
    {display:none;}
           .hideleft .main
    {left:0px;}

           
    /* HACK:*IE6/7 _IE6*/
           html 
    { *padding:50px 0px 50px 0px;}
           .panel
    {*position:relative;}
           .top 
    { *margin-top:-50px; *margin-bottom:0px; }
           .left 
    { *height:100%; *float:left; *top:0px;  }
           .main 
    { *height:100%;  *top:0;*left:0px;_left:-3px;}/*IE 6 float 3px bug*/
            .hidetop
    {*padding-top:0px;}
            .hidebottom
    {*padding-bottom:0px;}
            .hideleft
    {*padding-left:0px;}

          
    </style>
          
    <script type="text/javascript">
            
    function toggleClass(dom,className){
                
    var reg = new RegExp(className,"g"),
                    cn 
    = dom.className,
                    newcn
    = cn.indexOf(className)==-1?(cn+" "+className):cn.replace(reg,"");
                dom.className
    =newcn;
            }
          
    </script>
         
    </head>
         
    <body>
          
    <div class="panel top">頂部內(nèi)容(iframe上scrolling="yes" style="overflow:visible;"防止IE6出現(xiàn)iframe橫向滾動條)</div>
          
    <div class="panel left">
            
    <input type="button" id="" name="" value="收起/顯示上部" onclick="toggleClass(document.getElementsByTagName('html')[0],'hidetop')" />
            
    <br />
            
    <input type="button" id="" name="" value="收起/顯示左部" onclick="toggleClass(document.getElementsByTagName('html')[0],'hideleft')" />
            
    <br />
            
    <input type="button" id="" name="" value="收起/顯示下部" onclick="toggleClass(document.getElementsByTagName('html')[0],'hidebottom')" />
          
    </div>
          
    <div class="panel main" ><iframe frameborder="0"  scrolling="yes" style="overflow:visible;" src="http://www.baidu.com"></iframe></div>
          
    <div class="panel bottom">底部內(nèi)容</div>
         
    </body>
        
    </html>

    代碼很簡潔,看著也很舒服,在IE6下也能堅(jiān)強(qiáng)的正確的顯示著。

    可以參考blueidea論壇里面的這個(gè)經(jīng)典的帖子:

    http://bbs.blueidea.com/thread-2818595-4-1.html

    posted on 2011-06-17 12:26 衡鋒 閱讀(6325) 評論(5)  編輯  收藏 所屬分類: javascript 、Web開發(fā)

    評論

    # re: 使用div模擬出frameset效果 2011-06-18 05:59 Shor

    似乎現(xiàn)在用jquery實(shí)現(xiàn)類似的功能更加美觀容易. 不知道jquery對老一代瀏覽器的支持如何.  回復(fù)  更多評論   

    # re: 使用div模擬出frameset效果 2011-06-18 10:19 陽衡鋒

    @Shor
    jQuery的有borderlayout插件http://layout.jquery-dev.net/。非常好用。對于比較簡單的布局可以采用上述做法。  回復(fù)  更多評論   

    # re: 使用div模擬出frameset效果 2011-06-20 17:23 楊文勝

    newcn= cn.indexOf(className)==-1?(cn+" "+className):cn.replace(reg,"");
    這沒太讀懂,解釋一下可以不,陽哥  回復(fù)  更多評論   

    # re: 使用div模擬出frameset效果 2011-06-20 17:29 陽衡鋒

    @楊文勝
    這不就是如果className里面有那個(gè)class了就把他替換,否則給他加在最后面么。
    if(cn.indexOf(className)==-1){
    newcn=(cn+" "+className):
    }else{
    newcn = cn.replace(reg,"");
    }  回復(fù)  更多評論   

    # re: 使用div模擬出frameset效果 2011-09-15 08:33 tb

    剛好用到   回復(fù)  更多評論   

    主站蜘蛛池模板: 亚洲AV综合色区无码二区爱AV| 精品国产_亚洲人成在线高清| 在线综合亚洲中文精品| 中文字幕免费视频一| 久久精品a亚洲国产v高清不卡| 久久国产精品免费专区| 亚洲AV美女一区二区三区| 午夜视频免费在线观看| 亚洲最大的成网4438| 午夜性色一区二区三区免费不卡视频| 亚洲高清无在码在线电影不卡 | 色婷婷综合缴情综免费观看| 日韩一区二区三区免费体验| 18禁亚洲深夜福利人口| 亚洲综合最新无码专区| 在线免费视频你懂的| 亚洲AV永久纯肉无码精品动漫| 日韩精品无码一区二区三区免费| 亚洲精品电影在线| 久久不见久久见中文字幕免费 | 99re免费视频| 亚洲av无码专区在线| 免费视频淫片aa毛片| 一级成人a做片免费| 亚洲av无码乱码国产精品| 97性无码区免费| 欧美激情综合亚洲一二区| 久久精品国产精品亚洲下载| 一区二区免费视频| 亚洲色偷偷色噜噜狠狠99| 亚洲男女内射在线播放| 美女被cao网站免费看在线看| 亚洲婷婷综合色高清在线| 亚洲欧洲精品在线| 男男黄GAY片免费网站WWW| 亚洲婷婷综合色高清在线| 亚洲av日韩专区在线观看| 黄网站免费在线观看| 久久亚洲AV永久无码精品| 亚洲狠狠ady亚洲精品大秀| 国产免费看插插插视频|