国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

用CSS構建iframe效果

2020-10-23 18:50:31
字體:
來源:轉載
供稿:網友

iframe應用很普遍,通常的需求有兩種:
1,獲取iframe效果,就是帶一個滾動條,可以省不少版面。
2,要嵌一個頁面,實現框架鏈接。
如果不方便使用iframe,可以有如下解決方案:
第一種需求如果我們使用CSS布局來實現,即可以少一個頁面,也可以提高效率。
第二種需求可以采用xmlhttp遠程獲取。
A. 直接模擬iframe
用層做容器 

復制代碼 代碼如下:

#content { overflow:auto; height:200px; width:600px; background:#f00;}


[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執行]

用body做容器
復制代碼 代碼如下:
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需再刷新一下頁面才能執行]

B. 絕對定位模擬iframe
滾動條在外邊
復制代碼 代碼如下:
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需再刷新一下頁面才能執行]

滾動條在里邊
復制代碼 代碼如下:

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需再刷新一下頁面才能執行]

在IE6.0和FF1.5環境下測試通過

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 齐齐哈尔市| 姜堰市| 南雄市| 莎车县| 石嘴山市| 临沧市| 广德县| 南康市| 新兴县| 子长县| 赤城县| 济南市| 宁城县| 苗栗县| 弥渡县| 西盟| 渭南市| 横峰县| 墨竹工卡县| 惠水县| 汉沽区| 宁都县| 绥芬河市| 砀山县| 利辛县| 安平县| 文安县| 屯门区| 武冈市| 莱州市| 宁南县| 屏边| 郎溪县| 红河县| 栾城县| 开封县| 若尔盖县| 西盟| 田阳县| 罗山县| 湖口县|