translateY doesn't work when added from jQuery.css() function,
Scale and Opacity work fine, but translateY doesn't!
$(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();
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.