参考:
https://www.cnblogs.com/majingyi/p/6840818.html
https://www.cnblogs.com/sky903700252/p/7382808.html
var head= document.getElementById("head");
head.style.width = "200px";
head.style.height = "70px";
head.style.display = "block";
将多行简化成一行,减少渲染:
var head= document.getElementById("head");
head.style.cssText="width:200px;height:70px;display:bolck";
但cssText也有个缺点,会覆盖之前的样式。
可以在前面添加一个分号来解决这个问题:
Element.style.cssText += ';width:100px;height:100px;top:100px;left:100px;'