gpt4 book ai didi

css - Phonegap - CSS Flexbox - div 填充页面的其余部分

转载 作者:太空宇宙 更新时间:2023-11-04 12:03:04 25 4
gpt4 key购买 nike

我在正确设置 flexbox 方面遇到了问题。我试过设置 here. .我希望带有 run-map 类的 div 填满页面的其余部分,但我就是不明白。

body {
height:100% !important;
}

html {
}

.box {
display: flex;
flex-flow: column;
justify-content: center;
align-content: stretch;
align-items: stretch;
}

.box div.header {
order: 0;
flex: 0 1 auto;
align-self: auto;
}

.box div.run-data {
order: 1;
flex: 1 1 auto;
align-self: auto;
background-color: blue;
}

.box div.run-map {
order: 2;
flex: 2 1 auto;
align-self: auto;
background-color: red;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Title</title>
</head>
<body>
<div id="app" class="box">
<div class="header">
<table id="header-table">
<th onclick="loadContent('main.html')">Home</th>
<th onclick="loadContent('run.html')">Run</th>
<th>Statistics</th>
<th>Settings</th>
<th>Donate</th>
</table>
</div>
<div id="content" class="content-box">
<div class="run-data">
<script type="text/javascript">onload_run();</script>
<h1><span id="stopwatch">00:00:00</span></h1>
<p>Latitude: <span id="latitude"></span></p>
<p>Longitude: <span id="longitude"></span></p>
<p>Altitude: <span id="altitude"></span></p>
<p>Accuracy: <span id="accuracy"></span></p>
<p>Altitude Accuracy: <span id="altitude-accuracy"></span></p>
<p>Distance: <span id="distance"></span> km</p>
<p>Pace: <span id="pace"></span> min/km</p>
<input type="button" value="Start" onclick="start();">
<input type="button" value="Stop" onclick="stop();">
<input type="button" value="Reset" onclick="reset();">
</div>
<div class="run-map">
<script type="text/javascript">
//Load in the Map right at the beginning
Map.initialize();
</script>
</div>
</div>
</div>
</body>
</html>

如何让最后一个 div(运行图)填满页面的其余部分?

最佳答案

你想让红框在蓝框的下面还是旁边?这是一个红色框显示在蓝色框右侧的示例。

作为“填充页面其余部分的 flexbox 元素”的规则,确保添加 height: 100%<html>标记和包含要填充页面其余部分的元素的容器。

body {
height: 100%;
margin: 0;
}
html {
height: 100%;
}
.box {
display: flex;
flex-flow: column;
justify-content: center;
align-content: stretch;
align-items: stretch;
height: 100%;
}
.box div.header {
order: 0;
flex: 0 1 auto;
align-self: auto;
}
.box div.run-data {
order: 1;
flex: 1 1 auto;
align-self: auto;
background-color: blue;
}
.content-box {
height: 100%;
display: flex;
}
.box div.run-map {
order: 2;
flex: 2 1 auto;
align-self: auto;
background-color: red;
}
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title>Title</title>
</head>

<body>
<div id="app" class="box">
<div class="header">
<table id="header-table">
<th onclick="loadContent('main.html')">Home</th>
<th onclick="loadContent('run.html')">Run</th>
<th>Statistics</th>
<th>Settings</th>
<th>Donate</th>
</table>
</div>
<div id="content" class="content-box">
<div class="run-data">
<script type="text/javascript">
onload_run();
</script>
<h1><span id="stopwatch">00:00:00</span></h1>
<p>Latitude: <span id="latitude"></span>
</p>
<p>Longitude: <span id="longitude"></span>
</p>
<p>Altitude: <span id="altitude"></span>
</p>
<p>Accuracy: <span id="accuracy"></span>
</p>
<p>Altitude Accuracy: <span id="altitude-accuracy"></span>
</p>
<p>Distance: <span id="distance"></span> km</p>
<p>Pace: <span id="pace"></span> min/km</p>
<input type="button" value="Start" onclick="start();">
<input type="button" value="Stop" onclick="stop();">
<input type="button" value="Reset" onclick="reset();">
</div>
<div class="run-map">
<script type="text/javascript">
//Load in the Map right at the beginning
Map.initialize();
</script>
</div>
</div>
</div>
</body>

</html>

关于css - Phonegap - CSS Flexbox - div 填充页面的其余部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29592106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com