Luk*_*per 2 javascript jquery viewport-units
$(window).scroll(function() {
$scrollingDiv.css("display", (($(window).scrollTop() / $(document).height()) > 0.1) ? "block" : "");
});
Run Code Online (Sandbox Code Playgroud)
如何将单位更改$(document).height()) > 0.1)
为 100vh?我没有太多的 jQuery 经验。
VH:视口高度类似于$(window).height();
源
所以你可以检查条件if (windowHeight > 0.1)
然后
$("body").height(windowHeight);
Run Code Online (Sandbox Code Playgroud)
代码:
$(document).ready(function() {
var windowHeight = $(window).height();
if (windowHeight > 0.1) {
alert("height is greater than 0.1");
$("body").height(windowHeight);
} else {
alert("height is less than 0.1");
}
});
Run Code Online (Sandbox Code Playgroud)
Codepen 链接:https ://codepen.io/anon/pen/GWzVwO
归档时间: |
|
查看次数: |
14408 次 |
最近记录: |