Pol*_*Pol 6 html css tailwind-css
h-screen应该将高度设置为屏幕高度的类在 iOS 上不起作用。有没有办法解决这个问题?
fah*_*odi 41
遇到同样的问题,发现我们可以使用dvh(动态视口高度)。
h-[calc(100dvh)]代替h-screen。
但是,最好添加后备,以防万一。
NEO*_*JPK 35
.inset-0我经常发现在类的内容之外设置绝对包装器很有用
<!-- this will use the whole viewport even in mobile -->
<div class="absolute inset-0">
<div>
lorem ipsum
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
小智 8
在您的应用程序负载上运行此 JavaScript 代码
document.documentElement.style.setProperty("--vh", window.innerHeight * 0.01 + 'px');
并将其放在您的全局样式中以覆盖 h-screen 类
.h-screen {
height: 100vh; /* Fallback for browsers that do not support Custom Properties */
height: calc(var(--vh, 1vh) * 100);
}
Run Code Online (Sandbox Code Playgroud)
问题是h-screen用作100vh高度。正如此问题中提到的\xe2\x80\x99s 所示,100vh 的目标是不适用于移动设备。
但是有一个方法可以欺骗它,但是它不会\xe2\x80\x99被添加到tailwind中,因为它需要JS。要了解有关此 \xe2\x80\x98trick\xe2\x80\x99 的更多信息,请查看此文章:在移动设备上查看端口单位的技巧
\n