[英]how to write javascript value in translate3d css
I want to write my javascript value to translate a CSS class, however it is not working as I want. 我想写我的JavaScript值来翻译CSS类,但是它不能按我的要求工作。 Can anyone tell me why?
谁能告诉我为什么?
var contentHeight = $('#mainContentHeight')[0].scrollHeight;
$('#menu').css({
transform: "translateY(' + contentHeight + 'px)"
})
The issue is because you have mismatched quotes; 问题是因为您的报价不匹配;
"
as the outer delimiters and '
around where you concatenate the variable. Try this: "
作为外部定界符,并在连接变量'
周围加上'
。请尝试以下操作:
var contentHeight = $('#mainContentHeight')[0].scrollHeight;
$('#menu').css({
transform: 'translateY(' + contentHeight + 'px)'
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.