iframe内容自适应高度
一直觉得要用JS才能实现iframe高度的自适应,其实CSS也可以,而且实现的更好,只是需要给包裹iframe的DIV设置个高度,然后让irame高度设置成100%就可以自适应了。
完美版Iframe自适应高度====>推荐使用 <!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>iframe高度自适应</title>
<style>
*{margin:0; padding:0;}
html,body{height:100%;}
.header{width: 100%;height:50px;background: #11c1f3; }
.container{padding:0 0 0 200px;overflow: hidden;}
.container .main{position:absolute; width:auto; height:auto; top:50px; left:200px; right:0; bottom:0; overflow:hidden;}
.container .left{width:200px; height:auto; background:#ef473a; position:absolute; left:0; top:50px; bottom:0; overflow: auto;}
</style>
</head>
<body> <div class="header">顶部导航区域...</div>
<div class="container">
<div class="main">
<iframe class="mainFrame" src="http://www.cnblogs.com/leyi" width="100%" height="100%" frameborder="0"></iframe>
</div>
<div class="left">左侧导航区域...</div>
</div>
</body>
</html>
table版Iframe自适应高度打造高度自适应的后台布局框架=====> <style>
*{ margin:0; padding:0}
body, html{ height:100%; width:100%; overflow:hidden;} /*这个高度很重要*/
#frametable .header{ height:40px; background:#ddd; border-bottom:2px solid #999;}
#frametable .left{ width:150px; border-right:2px solid #999; background:#ddd; height:100%;}
</style> <table id="frametable" cellpadding="0" cellspacing="0" width="100%" height="100%" style="width: 100%;">
<tr>
<td colspan="2" height="40">
<div class="header">
<!-- header menu -->
</div>
</td>
</tr>
<tr>
<td valign="top" width="150" height="100%"> <!--这个高度很重要-->
<div class="left"><!-- left menu --></div>
</td>
<td valign="top" width="100%" height="100%"> <!--这个高度很重要-->
<iframe id="iframe" name="main" src="http://www.baidu.com" width="100%" allowtransparency="true" width="100%" height="100%" frameborder="0" scrolling="yes" style="overflow:visible;"></iframe>
</td>
</tr>
</table>
操作iframe=====>
contentWindow //所有浏览器都支持的
contentDocument //ie 6 7 不支持
document.getElementById('iframe_id').contentWindow.document.getElementById('子页面元素节点');
window.parent //子frame操作父级页面
window.parent.document.getElementById('父页面元素节点').style.cssText=..
window.top //获取最顶层一级页面
window.top.document.getElementById('最顶层页面元素节点').style.cssText=..
//防止被嵌套:
if(window!=window.top){
window.top.location.href=window.location.href
}
iframe的传值方式=====>
1、jsonp
2、localstorage
3、postMessage
iframe内容自适应高度的更多相关文章
- Jquery实现textarea根据文本内容自适应高度
本文给大家分享的是Jquery实现textarea根据文本内容自适应高度,这些在平时的项目中挺实用的,所以抽空封装了一个文本框根据输入内容自适应高度的插件,这里推荐给小伙伴们. autoTextare ...
- jQuery实现iframe的自适应高度
假设我们在当前页面要嵌套一个iframe 1 <iframe id="myframe" src="test.html" height="240& ...
- html5 textarea 文本框根据输入内容自适应高度
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- iframe 随内容自适应高度
兼容性好的 html代码: <iframe src="enterprise/enter_edit.aspx" id="mainframe" framebo ...
- iframe框架自适应高度 uncanght SecurityError: Blocked a frame with origin "null" from accessing a frame ....
来源于crm项目的contact/edit.html 一.背景是这样的 最近在做crm系统的前端页面,有一个页面呢,点击“查看全部信息”时会弹出,这个弹窗里面又有分页导航,分页不是使用ajax 异步刷 ...
- IOS UILabel 根据内容自适应高度
iOS Label 自适应高度 适配iOS7以后的版本 更多 self.contentLabelView = [[UILabel alloc] init]; self.contentLabelVie ...
- 关于使用iframe标签自适应高度的使用
在ifrome内设定最小高度,(此方法只适用于页面内切换高度不一.但是会保留最大高度,返回后保持最大高度不再回到最初页面的高度) <iframe id="one4" widt ...
- ios label根据内容自适应高度
label自适应高度,想必大家也都很熟悉怎么去做,上代码: UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(150, 50, 15 ...
- MiniUi遇到的一个Bug或者说坑,以div里面的内容自适应高度
页面源码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <tit ...
随机推荐
- Java基础_0303:封装性初步
class Book { // 定义一个新的类 private String title; // 书的名字 private double price; // 书的价格 public void getI ...
- Java之@SuppressWarnings
用了这个,MyEclipse里就不会报那些警告了,看起来漂亮多了 常用的:@SuppressWarnings("unchecked"),泛型@SuppressWarnings(&q ...
- ES6走一波 Generator异步应用
Generator 函数的异步应用 JS异步编程 callback Promise(解决回调地狱) 事件 发布订阅 generator Thunk函数 屁股函数 两次高阶调用的函数 第一次调用的入参 ...
- HDFS笔记(一)
1. HDFS 是什么? Hadoop分布式文件系统(Distributed File System)-HDFS(Hadoop Distributed File System) 2. HDFS 架构 ...
- mysql查询反斜杠字符串问题
马上上线发现一个问题,太坑了 写一个查询语句,明明数据库中有,但是就是查不到,后来发现是反斜杠的问题 比如 数据库中有一个字段名称为 name 存储的值为 “海尔厨电\洗碗机” 当我使用如下sql查 ...
- wx小程序-音频视频!
1.音乐的启动跟暂停 dom里面图片切换的另一种方法 通过变量 改变路径 2.监听 在onload里面 3.定义了一个全局变量 然后在但页面中获取 app.js 单页面中 app.js 的三个生命周期
- Css - 三大特性
css - 三大特性 1.层叠性 如果通过两个相同选择器设置了同一个元素的某个相同的css属性,按照css相同属性的出现顺序,后面的样式会覆盖前面的样式 2.继承性 祖先元素的关于文本的样式会遗传给后 ...
- npm 的 --save 和 --save-dev 的区别
--save-dev 是作为开发依赖保存到 packsge.json 中的 devDependencies 中,即在开发环境中用到的依赖,如 webpack.babel 等用于开发打包的依赖,只是在执 ...
- 基于ip的虚拟主机配置——在一台服务器上绑定多个 IP 地址
进入/etc/sysconfig/network-scripts,修改ifcfg-ens33文件 输入 ip addr 查看ip 引用:https://blog.csdn.net/u013887008 ...
- Python学习-环境搭建(IronPython)
一.IDE环境 VS2013 下安装 PTVS 2.2.2 VS 2013 VS2015 已经集成了Python的开发环境 二.安装 IronPython 下载地址:http://ironpytho ...