如何在translate3d css中编写javascript值
我想写我的javascript值来翻译CSS类,但是它没有按照我想要的那样工作。谁能告诉我为什么如何在translate3d css中编写javascript值,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我想写我的javascript值来翻译CSS类,但是它没有按照我想要的那样工作。谁能告诉我为什么 var contentHeight=$('#mainContentHeight')[0]; $(“#菜单”).css({ 转换:“translateY('+contentHeight+'px)” }) 问题在于您的报价不匹配“作为外部分隔符,并在连接变量的位置周围使用”。请尝试以下操作: var contentHeight = $('#mainContentHeight')[0].scrollHei
var contentHeight=$('#mainContentHeight')[0];
$(“#菜单”).css({
转换:“translateY('+contentHeight+'px)”
})
问题在于您的报价不匹配“
作为外部分隔符,并在连接变量的位置周围使用”
。请尝试以下操作:
var contentHeight = $('#mainContentHeight')[0].scrollHeight;
$('#menu').css({
transform: 'translateY(' + contentHeight + 'px)'
})
这个问题是因为您的引号不匹配;
“
作为外部分隔符,而”
位于连接变量的位置。试试这个:
var contentHeight = $('#mainContentHeight')[0].scrollHeight;
$('#menu').css({
transform: 'translateY(' + contentHeight + 'px)'
})
完美的非常感谢你的帮助。太好了!非常感谢你的帮助。