html - next.js 中的 div 高度不是 100%
问题描述
我在设置 next.js 中的页面时遇到问题。我想要全高页面。
因此,我在 body 和 html 标签中设置了 height 属性,没关系,我有 body 和 html 标签的全高(在开发工具中证明)但是虽然我将 #__next 高度设置为 100%,但我无法实现全高它。如果我应用 px 或 vh 等其他测量值,它就会受到影响。
布局.css
html {
height: 100%;
font-size: 16px;
}
body {
min-height: 100%;
font-family: @text-font-family;
direction: rtl !important;
text-align: start !important;
}
#__next {
height: 100%; // or min-height
}
解决方案
position: absolute;
可能对你有用
html,
body {
margin: 0;
}
#__next {
background: blue;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
<div id="__next"></div>
推荐阅读
- ios - 应用程序进入后台时如何发送本地通知
- mongodb - 错误:未加载 mongodb.jdbc.MongoDriver。你确定你已经包含了正确的 jdbc 驱动程序
- java - 如何有效地返回给定位数的最大可能整数
- javascript - 在 symfony4 树枝模板中分离 JavaScripts 文件
- image - 如何在 vuetify 中设置轮播图像的大小
- string - 多行中的 LLVM IR 字符串文字
- java - 如何在使用 Logstash 摄取到 ElasticSearch 的 JSON 文件中使用 Java 处理 HTML 内容?
- django-forms - 使用 django-form 在 ParentalManyToManyField wagtail 中检查默认特定选项
- javascript - 如何使用 AWS IoT 组一次更新组设备影子?
- vba - VBA向使用RangetoHTML(rng to Range)功能的电子邮件添加签名