首 页 | 精品电影 | 音乐天堂 | 在线游戏 | Flash MTV | 三湘书屋 | 幽默笑话 | 三湘图库 | 美女写真 | IT知识库 | QQ贴图 | 加入书签

网页制作网络编程图形图象操作系统冲浪宝典软件教学网络安全认证考试通信技术电子商务业内动态书籍教程原码

最近更新 文章分类 多媒体类 精品软件

本站搜索:
您的位置:三湘时空 -> IT知识库 -> 文章分类 -> CSS教程 -> 超强,用CSS构建iframe效果
超强,用CSS构建iframe效果


文章类别:CSS教程 来源: 作者: 发表日期:2006-4-5 字体:[ ]

小游戏 | 在线影院 | 幽默笑话 | 源码下载 | Flash MTV | 音乐试听 | 书屋 | 美女写真

iframe应用很普遍,通常的需求有两种:

1,获取iframe效果,就是带一个滚动条,可以省不少版面。
2,要嵌一个页面,实现框架链接。

如果不方便使用iframe,可以有如下解决方案:

第一种需求如果我们使用css布局来实现,即可以少一个页面,也可以提高效率。
第二种需求可以采用xmlhttp远程获取。

A. 直接模拟iframe

用层做容器

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

效果演示源代码:



用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%;}


效果演示源代码:



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;}


效果演示源代码:




滚动条在里边

  引用:
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;}


效果演示代码:




在IE6.0和FF1.5环境下测试通过

上一篇:玩QQ空间常遇到的问题及解决办法 下一篇:攻防实战:注水漏洞的利用和防范
本栏目热门文章
·CSS+DIV设计实例:实现让多个DIV排列时居中 2006-5-28
·引入CSS样式的五种方式 2006-5-28
·CSS+DIV设计实例:纯CSS制作下拉导航菜单 2006-5-28
·超强,用CSS构建iframe效果 2006-4-5
·CSS实用教程(一) 2005-10-4
·SPAN和DIV的区别 2006-3-18
·利用CSS,不通过replace替换标引HTML标记 2005-10-4
·拒绝单调 让网页超链接拥有多姿多彩的下划线 2005-10-4
·css学习的一些心得 2005-12-13
·对display:inline;与float:left;的认识 2006-6-4
新近更新文章
·用CSS打造可折叠伸缩名片菜单 2006-6-15
·用CSS做滑动效果的图片画廊 2006-6-15
·CSS+DIV:让文本字符环绕在你的图片周围 2006-6-15
·用相对定位和负向移动完成图片象框阴影 2006-6-15
·CSS里也能写脚本? 2006-6-12
·CSS初级入门:页面样式的整体声明 2006-6-9
·CSS初级入门:样式的多次声明 2006-6-9
·用CSS实现表格背景颜色渐变效果 2006-6-6
·认识CSS中absolute与relative 2006-6-4
·对display:inline;与float:left;的认识 2006-6-4
首 页 | 软件发布 | 广告联系 | 下载帮助 | 意见反馈 | 网站地图
  CopyRight? 2002-2004 WWW.SXSKY.NET? All Rights Reserved
三湘时空 站长QQ:82675303 Email: