css iframe自适应高度(iframe的高度可以随内容的多少而变化吗)

:暂无数据 2026-09-08 17:00:03 :0

css iframe自适应高度(iframe的高度可以随内容的多少而变化吗)

大家好,今天小编来为大家解答以下的问题,关于css iframe自适应高度,iframe的高度可以随内容的多少而变化吗这个很多人还不知道,现在让我们一起来看看吧!

本文目录

iframe的高度可以随内容的多少而变化吗

iframe的高度可以随内容的多少而变化,解决方法如下:

1、首先在文件夹里创建两个html文件,一个“index”一个“iframe”。

2、然后在index中添加一个iframe标签,直接嵌入iframe页面。

3、接着在iframe网页中添加了两个固定高度的div内容。

4、浏览器打开index页面,发现iframe部分有滚动条,需要滚动显示页面。

5、现在在index页面的iframe标签再添加如下的属性。再次打开index页面iframe已经高度自适应了。

iframe的高度怎么根据内容的多少来决定它具体的高度请写清注释、谢谢

实现同域iframe高度自适应,可使用偶写的代码实现: 【aaaaa_1.html Code】《iframe id=“pa_frame“ src=“aaaaa_2.html“ frameborder=“0“ scrolling=“no“ width=“100%“》《/iframe》
《script type=“text/javascript“》
window.onload=function (){
var pa_frame=document.getElementById(’pa_frame’);
pa_frame.style.height=pa_frame.contentWindow.document.body.scrollHeight+’px’;
}
《/script》 【aaaaa_2.html Code】《style type=“text/css“》
body{margin:0;padding:0;}
《/style》
《p》1《/p》
《p》2《/p》
《p》3《/p》
《p》4《/p》
《p》5《/p》
《p》6《/p》
《p》7《/p》
《p》8《/p》
《p》9《/p》
《p》10《/p》

求助!!iframe 自适应高度 隐藏滚动条

你可以用Jquery控制iframe的宽和高。获取窗口可视部分的宽高设置给iframe
//文档加载完成时
$(document).ready(function(e) {
$(“iframe“).height($(window).height());
$(“iframe“).width($(window).width());
});
//为了适应用户取消了浏览器全屏时的效果,你还需加一个窗口改变时的事件
$(window).resize(function(){
$(“iframe“).height($(window).height());
$(“iframe“).width($(window).width());
});

iframe跨域自适应高度

《!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN“ “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“》
《html xmlns=“http://www.w3.org/1999/xhtml“》
《head》
《meta http-equiv=“Content-Type“ content=“text/html; charset=gb2312“ /》
《title》无标题文档《/title》
《style type=“text/css“》
body {
background-attachment:fixed;
margin: 0px;
}
#bottomNav {
z-index:999;
position:fixed;/*FireFox */
top: 0px;/*FireFox */
left:0;
right:0;
width:100%;
_position:absolute; /* for IE6 */
_top: expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight); /* for IE6 */
overflow:visible;
}
.nav{
width:960px;
margin-right: auto;
margin-left: auto;
}
.text{
width:930px;
background-color: #CCCCCC;
float: left;
}
.link{
width:30px;
background-color: #CCCCCC;
float: right;
text-align: center;
text-decoration: none;
}
#ifr{
width:100%;
}
《/style》

《script type=“text/javascript“》
function showHideDIV(){
var doc = document.getElementById(“Maple“);
doc.style.display =
(doc.style.display == “none“?“block“:“none“);
}

《/script》

《/head》

《body》

《div id=“bottomNav“》
《div class=“nav“》
《div id=“Maple“ class=“text“》固定漂浮物在此处O(∩_∩)O~《/div》《div class=“link“》《a href=“javascript:void(0);“ onclick=“showHideDIV()“》显《/a》《/div》
《/div》
《/div》

《iframe src=“http://www.youku.com“ scrolling=“no“ frameborder=“0“ id=“ifr“》《/iframe》

《/body》
《/html》

《!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN“ “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“》
《html xmlns=“http://www.w3.org/1999/xhtml“》
《head》
《meta http-equiv=“Content-Type“ content=“text/html; charset=gb2312“ /》
《title》无标题文档《/title》
《style type=“text/css“》
body {
background-attachment:fixed;
margin: 0px;
}
#bottomNav {
z-index:999;
position:fixed;/*FireFox */
top: 0px;/*FireFox */
left:0;
right:0;
width:100%;
_position:absolute; /* for IE6 */
_top: expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight); /* for IE6 */
overflow:visible;
}
.nav{
width:960px;
margin-right: auto;
margin-left: auto;
}
.text{
width:930px;
background-color: #CCCCCC;
float: left;
}
.link{
width:30px;
background-color: #CCCCCC;
float: right;
text-align: center;
text-decoration: none;
}
#ifr{
width:100%;
}
《/style》

《script type=“text/javascript“》
function showHideDIV(){
var doc = document.getElementById(“Maple“);
doc.style.display =
(doc.style.display == “none“?“block“:“none“);
}

《/script》

《/head》

《body》

《div id=“bottomNav“》
《div class=“nav“》
《div id=“Maple“ class=“text“》固定漂浮物在此处O(∩_∩)O~《/div》《div class=“link“》《a href=“javascript:void(0);“ onclick=“showHideDIV()“》显《/a》《/div》
《/div》
《/div》

《iframe src=“http://www.youku.com“ scrolling=“no“ frameborder=“0“ id=“ifr“》《/iframe》

《/body》
《/html》

《!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN“ “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“》
《html xmlns=“http://www.w3.org/1999/xhtml“》
《head》
《meta http-equiv=“Content-Type“ content=“text/html; charset=gb2312“ /》
《title》无标题文档《/title》
《style type=“text/css“》
body {
background-attachment:fixed;
margin: 0px;
}
#bottomNav {
z-index:999;
position:fixed;/*FireFox */
top: 0px;/*FireFox */
left:0;
right:0;
width:100%;
_position:absolute; /* for IE6 */
_top: expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight); /* for IE6 */
overflow:visible;
}
.nav{
width:960px;
margin-right: auto;
margin-left: auto;
}
.text{
width:930px;
background-color: #CCCCCC;
float: left;
}
.link{
width:30px;
background-color: #CCCCCC;
float: right;
text-align: center;
text-decoration: none;
}
#ifr{
width:100%;
}
《/style》

《script type=“text/javascript“》
function showHideDIV(){
var doc = document.getElementById(“Maple“);
doc.style.display =
(doc.style.display == “none“?“block“:“none“);
}

《/script》

《/head》

《body》

《div id=“bottomNav“》
《div class=“nav“》
《div id=“Maple“ class=“text“》固定漂浮物在此处O(∩_∩)O~《/div》《div class=“link“》《a href=“javascript:void(0);“ onclick=“showHideDIV()“》显《/a》《/div》
《/div》
《/div》

《iframe src=“http://www.youku.com“ scrolling=“no“ frameborder=“0“ id=“ifr“》《/iframe》

《/body》
《/html》

《!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN“ “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“》
《html xmlns=“http://www.w3.org/1999/xhtml“》
《head》
《meta http-equiv=“Content-Type“ content=“text/html; charset=gb2312“ /》
《title》无标题文档《/title》
《style type=“text/css“》
body {
background-attachment:fixed;
margin: 0px;
}
#bottomNav {
z-index:999;
position:fixed;/*FireFox */
top: 0px;/*FireFox */
left:0;
right:0;
width:100%;
_position:absolute; /* for IE6 */
_top: expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight); /* for IE6 */
overflow:visible;
}
.nav{
width:960px;
margin-right: auto;
margin-left: auto;
}
.text{
width:930px;
background-color: #CCCCCC;
float: left;
}
.link{
width:30px;
background-color: #CCCCCC;
float: right;
text-align: center;
text-decoration: none;
}
#ifr{
width:100%;
}
《/style》

《script type=“text/javascript“》
function showHideDIV(){
var doc = document.getElementById(“Maple“);
doc.style.display =
(doc.style.display == “none“?“block“:“none“);
}

《/script》

《/head》

《body》

《div id=“bottomNav“》
《div class=“nav“》
《div id=“Maple“ class=“text“》固定漂浮物在此处O(∩_∩)O~《/div》《div class=“link“》《a href=“javascript:void(0);“ onclick=“showHideDIV()“》显《/a》《/div》
《/div》
《/div》

《iframe src=“http://www.youku.com“ scrolling=“no“ frameborder=“0“ id=“ifr“》《/iframe》

《/body》
《/html》

有iframe让父页面自动调整高度

一般来说,父页面的高度是自动的,iframe高度再大,父页面也会自动适应的

除非楼主你的父页面设置了高度以及overflow:hidden之类的样式

另外iframe里面的内容超过1000px的话,而且iframe设置了没有滚动条的话,就没有滚动条了【这是后话】

或者楼主给出部分代码看看

如果你还想了解更多这方面的信息,记得收藏关注本站。

css iframe自适应高度(iframe的高度可以随内容的多少而变化吗)

本文编辑:admin

更多文章:


promote翻译(英语翻译倡导怎么说)

promote翻译(英语翻译倡导怎么说)

其实promote翻译的问题并不复杂,但是又很多的朋友都不太了解英语翻译倡导怎么说,因此呢,今天小编就来为大家分享promote翻译的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月11日 06:30

用手机如何导航?开车用手机导航哪个软件最好

用手机如何导航?开车用手机导航哪个软件最好

今天给各位分享用手机如何导航的知识,其中也会对用手机如何导航进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

2026年10月11日 06:20

多线程技术有什么用(多线程有什么作用)

多线程技术有什么用(多线程有什么作用)

其实多线程技术有什么用的问题并不复杂,但是又很多的朋友都不太了解多线程有什么作用,因此呢,今天小编就来为大家分享多线程技术有什么用的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月11日 05:40

another time(another time和other time的区别)

another time(another time和other time的区别)

大家好,another time相信很多的网友都不是很明白,包括another time和other time的区别也是一样,不过没有关系,接下来就来为大家分享关于another time和another time和other time的区

2026年10月11日 05:00

java开发工具包jdk(JDK是什么意思)

java开发工具包jdk(JDK是什么意思)

其实java开发工具包jdk的问题并不复杂,但是又很多的朋友都不太了解JDK是什么意思,因此呢,今天小编就来为大家分享java开发工具包jdk的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月11日 04:50

mysql 命令(MySQL的基本命令)

mysql 命令(MySQL的基本命令)

大家好,如果您还对mysql 命令不太了解,没有关系,今天就由本站为大家分享mysql 命令的知识,包括MySQL的基本命令的问题都会给大家分析到,还望可以解决大家的问题,下面我们就开始吧!

2026年10月11日 03:00

手机云备份是什么意思?手机上的云备份有什么用 怎么用呢

手机云备份是什么意思?手机上的云备份有什么用 怎么用呢

各位老铁们,大家好,今天由我来为大家分享云备份,以及手机云备份是什么意思的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,谢谢大家了哈,下面我们开始吧!

2026年10月11日 02:40

java遍历map的key(java Map 怎么遍历)

java遍历map的key(java Map 怎么遍历)

大家好,java遍历map的key相信很多的网友都不是很明白,包括java Map 怎么遍历也是一样,不过没有关系,接下来就来为大家分享关于java遍历map的key和java Map 怎么遍历的一些知识点,大家可以关注收藏,免得下次来找不

2026年10月11日 02:20

微信xlsx文件怎么打开(苹果手机微信打开excel)

微信xlsx文件怎么打开(苹果手机微信打开excel)

大家好,关于微信xlsx文件怎么打开很多朋友都还不太明白,不过没关系,因为今天小编就来为大家分享关于苹果手机微信打开excel的知识点,相信应该可以解决大家的一些困惑和问题,如果碰巧可以解决您的问题,还望关注下本站哦,希望对各位有所帮助!

2026年10月11日 01:10

reduce用法和短语(减少的英文短语有哪些)

reduce用法和短语(减少的英文短语有哪些)

其实reduce用法和短语的问题并不复杂,但是又很多的朋友都不太了解减少的英文短语有哪些,因此呢,今天小编就来为大家分享reduce用法和短语的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月11日 00:40

最近更新

promote翻译(英语翻译倡导怎么说)
2026-10-11 06:30:03 浏览:0
热门文章

标签列表