Javascript 多个div如何具有85%的高度和100%的宽度?
我的问题是有两个div,都有85%的高度和100%的宽度,但一次只显示一个。现在,第二个div显示得很奇怪 在此处查看并选择(菜单滑动->选择visa下的“graf”。) 在那里你会看到第二个div没有100%的宽度和85%的高度,我能用一种简单的方法解决这个问题吗 以下是HTML:Javascript 多个div如何具有85%的高度和100%的宽度?,javascript,html,css,Javascript,Html,Css,我的问题是有两个div,都有85%的高度和100%的宽度,但一次只显示一个。现在,第二个div显示得很奇怪 在此处查看并选择(菜单滑动->选择visa下的“graf”。) 在那里你会看到第二个div没有100%的宽度和85%的高度,我能用一种简单的方法解决这个问题吗 以下是HTML: <div id="mainContent"> <div id="googleMap"></div> <div id="GraphWindow">dw <ifr
<div id="mainContent">
<div id="googleMap"></div>
<div id="GraphWindow">dw
<iframe src="prototype.html" frameborder="" name="" width="" height="" scrolling="no"> Sorry your browser does not support frames or is currently not set to accept them.</iframe>
</div>
</div>
以下是显示或隐藏图形的javascript:
function selectMainView(){
if(document.details.title.value == "map"){
document.getElementById("googleMap").style.display = "block";
document.getElementById("GraphWindow").style.display = "none";
}
else{
document.getElementById("googleMap").style.display = "none";
document.getElementById("GraphWindow").style.display = "block";
}
}
为iframe设置高度和宽度属性
<iframe src="prototype.html" frameborder="" name="" width="100%" height="85%" scrolling="no"> Sorry your browser does not support frames or is currently not set to accept them.</iframe>
很抱歉,您的浏览器不支持帧或当前未设置为接受帧。
您的div
具有idGraphWindow
(大写G),您的css选择器为#GraphWindow
(小写G)
更换其中一个,使其与套管匹配
此外,您还应将iframe
更改为宽度和高度为100%将#GraphWindow
设置为#GraphWindow
。。。也许,拼写错误?!
仔细检查你的CSS,它区分大小写
(提示:尝试使用“firebug”,下次检查并调试!)如下修改CSS:
html {height:100%}
body {height:100%;margin:0;padding:0}
#mainContent{
height:85%;
width:100%;
margin-left: auto ;
margin-right: auto ;
}
#GraphWindow{
height:85%;
width:100%;
margin-left: auto ;
margin-right: auto ;
}
#GraphWindow iframe{
height:100%;
width:100%;
}
#googleMap {
height:85%;
width:100%;
margin-left: auto ;
margin-right: auto ;
}
解决什么?你们从来并没有真正说出你们想要什么。我只有在我有地图的时候才能看到地图,而当我点击图形的时候才能看到GraphWindow
。那么问题是什么呢?
html {height:100%}
body {height:100%;margin:0;padding:0}
#mainContent{
height:85%;
width:100%;
margin-left: auto ;
margin-right: auto ;
}
#GraphWindow{
height:85%;
width:100%;
margin-left: auto ;
margin-right: auto ;
}
#GraphWindow iframe{
height:100%;
width:100%;
}
#googleMap {
height:85%;
width:100%;
margin-left: auto ;
margin-right: auto ;
}