mbskys
如果你有很多关联的CSS文件要一起加载,或者想动态的加载不同的CSS文件,那么下面的方法你一定对你有帮助。
第一种:一般用在外部CSS文件中加载必须的文件
@import url(style.css);

/*只能用在CSS文件中或者style标签中*/ 


第二种:简单的在页面中加载一个外部CSS文件
document.createStyleSheet(cssFile);  


第三种:用createElement方法创建CSS的Link标签
 var head = document.getElementsByTagName(\'HEAD\').item(0); 

 var style = document.createElement(\'link\'); 

 style.href = \'style.css\'; 

 style.rel = \'stylesheet\'

 style.type = \'text/css\'; 

 head.appendChild(style);  

分类:

技术点:

相关文章:

  • 2021-12-05
  • 2021-12-05
  • 2021-12-13
  • 2021-07-01
  • 2021-12-27
  • 2021-12-05
  • 2021-12-23
  • 2021-07-25
猜你喜欢
  • 2021-12-05
  • 2021-12-26
  • 2021-12-06
  • 2021-12-23
  • 2021-12-05
  • 2022-01-05
  • 2021-12-05
相关资源
相似解决方案