![](/img/trans.png)
[英]Jquery/Javascript Math: Why are these two 1 line math problems not giving the same answer?
[英]JavaScript shorthand math on same line for defining CSS value
分配CSS樣式並在同一行上添加像素的快捷方式是什么? 以下內容不起作用,盡管應該格外清楚我要做什么:
header.style.top = (h + 100)+px;
header.style.top = (h + 100) + 'px';
我相信您不需要指定px
值。 默認為pixels
查看此問題: 使用Javascript向HTML元素添加寬度
如http://javascript.info/tutorial/styles-and-classes-getcomputedstyle所示,他們說將px括在方括號'px'
。 像上面的答案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.