我知道这是一个愚蠢的..但是将 html 和 body 标签的高度设置为 100% 并将填充和边距调整为 0 并没有解决它!
Divs 仍然没有显示正确的高度..而只是其内容的高度。
这是我的代码:
HTML
<!DOCTYPE html>
<html lang="e">
<head>
<meta charset="utf-8" />
<title>Musterportfoliovergleich</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="stylesheets/index.css" type="text/css">
<!--<link rel="stylesheet" href="stylesheets/jquery.mobile.css" type="text/css">-->
<script type="text/javascript" src="javascripts/jquery.js"></script>
<script type="text/javascript" src="javascripts/jquery.mobile.js"></script>
<script type="text/javascript">
$(document).ready(function() {
console.log("Hello");
});
</script>
</head>
<body>
<div id="pieChartCont1" class="container">
Pie Chart Container 1
</div>
<div id="barChartCont1" class="container">
<div id="barChartCont">
Bar Chart Container
</div>
<div id="recBut">
recBut
</div>
</div>
<div id="pieChartCont2" class="container">
Pie Chart Container 2
</div>
<div id="recCont" class="container">
Recomendations Container
</div>
<div id="barChartCont2" class="container">
Bar Chart Container 2
</div>
</body>
</html>
CSS
html, body{
width:100%;
height:100%;
margin:0;
}
#pieChartCont1{background-color:red}
#barChartCont{background-color:green}
#recBut{background-color:blue}
#pieChartCont2{background-color:yellow}
#recCont{background-color:purple}
#barChartCont2{background-color:orange}
@media
only screen and (orientation:portrait){
.container{
width:100%
}
#pieChartCont1{
height:45%
}
#barChartCont1{
height:10%
}
#barChartCont{
width:80%;
height:100%;
float:left;
}
#recBut{
width:20%;
height:100%;
float:left
}
#pieChartCont2{
height:45%
}
#recCont{display:none}
#barChartCont2{display:none}
}
@media
only screen and (orientation:landscape) and (max-device-width:700px){
.container{
height:100%;
float:left;
}
#pieChartCont1{
width:45%
}
#barChartCont1{
width:10%
}
#barChartCont{
width:100%;
height:80%
}
#recBut{
width:100%;
height:20%
}
#pieChartCont2{
width:45%
}
#recCont{display:none}
#barChartCont2{display:none}
}
@media
only screen and (orientation:landscape) and (min-device-width:701px){
.container{
width:50%;
height:50%;
float:left;
}
/*#pieChartCont1{}*/
/*#pieChartCont2{}*/
#recCont{
clear:both
}
/*#barChartCont2{}*/
#barChartCont1{display:none}
}
我想到了!jQuery Mobile 脚本只是弄乱了视图。