[英]how can multiple divs have 85% height and 100% width?
My question is regarding having 2 divs both having 85% height and 100% width, but only displaying one at a time. 我的问题是让2个div的高度和宽度分别为85%和100%,但一次只能显示一个。 As it is now the second div is displaying strangely. 现在,第二个div显示异常。
Have a look here and choose (menuslider->choose "graf" under visa.) There you will see that the second div is not having the width 100% and 85% height, can I solve this in an easy way? 看看这里并选择(签证下的menuslider-> choose“ graf”。)您将看到第二个div的宽度不为100%和高度为85%,我能以一种简单的方式解决此问题吗?
Here is the HTML: 这是HTML:
<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>
Here is the CSS: 这是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 ;
}
#googleMap {
height:85%;
width:100%;
margin-left: auto ;
margin-right: auto ;
}
Here is the javascript showing or hiding the graph: 这是显示或隐藏图形的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>
Your div
has id GraphWindow
(uppercase G) and your css selector is #graphWindow
(lowercase g). 您的div
ID为GraphWindow
(大写G),而CSS选择器为#graphWindow
(小写g)。
Change one of them to have them match casing. 更改其中之一以使它们与外壳匹配。
Also you should change the iframe
to have width
and height
of 100% 另外,您应该将iframe
更改为width
和height
为100%
Set #GraphWindow
to #graphWindow
... perhaps, spell error?! 将#GraphWindow
设置为#graphWindow
...也许拼写错误?! Check your CSS carefully, it's case sensitive! 仔细检查CSS,区分大小写!
(Tip: Try using "firebug", inspect and debug it next time!) (提示:尝试使用“萤火虫”,下次进行检查和调试!)
Modify your CSS like this: 像这样修改您的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 ;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.