|
iframe應(yīng)用很普遍,通常的需求有兩種:
1,獲取iframe效果,就是帶一個(gè)滾動(dòng)條,可以省不少版面。
2,要嵌一個(gè)頁(yè)面,實(shí)現(xiàn)框架鏈接。
如果不方便使用iframe,可以有如下解決方案:
第一種需求如果我們使用CSS布局來(lái)實(shí)現(xiàn),即可以少一個(gè)頁(yè)面,也可以提高效率。
第二種需求可以采用xmlhttp遠(yuǎn)程獲取。
A. 直接模擬iframe
用層做容器
復(fù)制代碼 代碼如下:
#content { overflow:auto; height:200px; width:600px; background:#f00;}
[Ctrl+A 全選 注:如需引入外部Js需刷新才能執(zhí)行]
用body做容器
復(fù)制代碼 代碼如下:html { overflow:hidden; height:100%; background:#fff; border:0;}
* html { padding:100px 0 0 100px;}
body { overflow:scroll; background:#f00; margin:0; position:absolute; top:100px; left:100px; bottom:0; right:0;}
* html body { height:100%; width:100%;}
[Ctrl+A 全選 注:如需引入外部Js需刷新才能執(zhí)行]
B. 絕對(duì)定位模擬iframe
滾動(dòng)條在外邊
復(fù)制代碼 代碼如下:html { overflow:hidden; border:0; height:100%; max-height:100%;}
body { overflow:hidden; margin:0; height:100%; max-height:100%; position:relative;}
#head { position:absolute; top:0; right:15px; width:100%; height:100px; background:#f00; z-index:2;}
#foot { position:absolute; bottom:0; right:15px; width:100%; background:#f00; height:50px;z-index:2;}
#content { height:100%; position:relative; z-index:1; overflow:auto;}
效果演示源代碼:
[Ctrl+A 全選 注:如需引入外部Js需刷新才能執(zhí)行]
滾動(dòng)條在里邊
復(fù)制代碼 代碼如下:
html { height:100%; max-height:100%; border:0; overflow:hidden;}
* html { padding:100px 0 50px 0;}
body { height:100%; max-height:100%; margin:0; overflow:hidden;}
#content { position:absolute; top:100px; bottom:50px; left:0; right:0; z-index:3; width:100%; overflow:auto;}
* html #content { top:100px; bottom:0; height:100%;}
#head { position:absolute; margin:0; top:0; left:0; width:100%; height:100px; background:#f00; z-index:5;}
#foot { position:absolute; margin:0; bottom:0; left:0; width:100%; height:50px; z-index:5; background:#f00;}
[Ctrl+A 全選 注:如需引入外部Js需刷新才能執(zhí)行]
在IE6.0和FF1.5環(huán)境下測(cè)試通過(guò)
HTML/CSS技術(shù):用CSS構(gòu)建iframe效果,轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。