css - 将 html、body、.App 和 #root 设置为 100% 高度后,Div 不会占用剩余空间
问题描述
看起来 html 元素占据了整个页面,由于某种原因,body 顶部有一点空隙,但我的 div 仍然不会占用剩余的空间。
这是浏览器中的 html 树
应用程序.css:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: nunito;
}
html,
body,
#root,
.App {
height: 100%;
width: 100%;
}
HistorySheet.jsx
if (!loading) {
return (
<div className="historySheet">
<Searchbar
location={location}
changeLocation={changeLocation}
weatherData={weatherData}
/>
<div className="backdrop">
<div className="headers">
<p>Date</p>
<p>Avg</p>
<p>High</p>
<p>Low</p>
<p>Phase</p>
</div>
{results()}
<img onClick={addResults} src={expand} alt="expand icon" />
</div>
</div>
);
} else {
return <p>Loading...</p>;
}
HistorySheet.css
.historySheet {
max-width: 60%;
display: flex;
flex-direction: column;
align-items: center;
margin: auto;
height: 100%;
}
.backdrop {
width: 100vw;
background: #468faf;
padding: 1.5rem 17rem;
}
.headers {
width: 100%;
display: grid;
align-items: center;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
text-align: center;
color: white;
font-weight: 300;
}
.results {
height: 100%;
}
我试过在所有东西上做 min-width ,但它没有改变。
解决方案
如果您希望 historySheet 具有 100% 的宽度,那么您需要从 .historySheet中删除max-width
推荐阅读
- javascript - How to control Tamper Monkey dashboard Installed script, so that user cannot disable a script
- excel - 将excel sheet的数据与neo4j中的相关数据进行对比
- python - How would I loop the triangles/improve my code? (Nested triangle turtle)
- node.js - Loopback: Creating relations between models in different microservices
- python - Finding shortest sublist with sum greater than 50
- spring-webflux - Spring Cloud Contract EXPLICIT 和 WEBTESTCLIENT 测试模式
- appium - 跳过某些关键字的“捕获页面截图”
- python - 如何在条件下从数据框中选择多列和多行?
- html - flex-wrap: nowrap 与行和列
- php - 通过 axios 请求调用 php 文件已被 VUE CLI 3 中的 CORS 策略阻止