[英]translateY doesn't work when added from jQuery .css() function
translateY doesn't work when added from jQuery.css() function,从 jQuery.css() function 添加时 translateY 不起作用,
Scale and Opacity work fine, but translateY doesn't! Scale 和 Opacity 工作正常,但 translateY 不行!
$(function () {
$(window).scroll(function () {
bds = $("body").scrollTop();
myScale = 1.2 - (bds / 1000);
myOPacity = 1 - (bds / 100);
myTransform = bds;
$(".slogan").css({
"transform": "translateY(" + myTransform +"px) scale( " + myScale + ")",
opacity: myOPacity
});
});
It seems that you should only change bds = $("body").scrollTop();
看来您应该只更改
bds = $("body").scrollTop();
as this:像这样:
<script>
$(document).ready(function () {
$(window).scroll(function () {
bds = $(window).scrollTop();
myScale = 1.2 - (bds / 1000);
myOPacity = 1 - (bds / 100);
myTransform = bds;
$(".slogan").css({
"transform": "translateY(" + myTransform + "px) scale( " + myScale + ")",
opacity: myOPacity
});
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.