gpt4 book ai didi

javascript - 为什么我不能让我的 div 填满我的窗口的 100%?

转载 作者:行者123 更新时间:2023-11-28 04:31:28 24 4
gpt4 key购买 nike

我试图让一个 div 以 100% 的窗口高度 (640px) 显示,but it only seems to render the height<h3> .我看不出我做错了什么。我在模拟器中运行应用程序,它与 Cordova 有关系吗?

$(window).height(); // This is 640px.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test</title>
</head>
<body>
<!-- Cordova scripts here -->

<div style="height: 100%;" >

<div id="d1" style="background-color: coral; height: 100%;">
<h3>A div test.</h3>

</div>

</div>

</body>
</html>

最佳答案

您应该将其设置为视口(viewport)的 100%:

height: 100vh;

关于javascript - 为什么我不能让我的 div 填满我的窗口的 100%?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33342397/

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