2020-3-27原生JS/ZL2:js改变css样式的三种方法

1、第一种:用cssText
div.style.cssText=‘width:600px;height:250px;border:1px red solid;text-align: center;line-height: 250px;’;
2、第二种:用setProperty()
div.style.setProperty(‘width’,‘700px’);
3、第三种:使用css属性对应的style属性
div.style.textAlign = “center”;

发布了11 篇原创文章 · 获赞 0 · 访问量 39

猜你喜欢

转载自blog.csdn.net/qq_25787687/article/details/105143671