如何以编程方式将CSS定义应用于整个页面? [英] How to programmatically apply CSS definitions to the whole page?

查看:85
本文介绍了如何以编程方式将CSS定义应用于整个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定信息已经存在,但我找不到;对不起: - /



我想使用JavaScript创建CSS规则,并将它们应用到整个页面,就像它们在文档头部的样式元素中一样。我不想通过生成CSS文本 - 我想保持规则作为实体(JavaScript变量),我可以更改,从而改变以后的页面的外观。


$

解决方案

我找到了我想要的:http://www.javascriptkit.com/dhtmltutors/externalcss3.shtml



(感谢所有已经回答和评论的人,我想要的 - 最后发现,看到上面的链接 - 是一个实际的CSS规则对象,我可以动态地工作,就像HTML元素一样。答案接近,没有一个是正确的。)


I'm sure the information already exists, but I couldn't find it; sorry :-/

I want to create CSS rules using JavaScript, and apply them to the whole page, as if they were in a style element in the document's head. I don't want to do it by generating the CSS text - I want to keep the rules as entities (JavaScript variables) that I can change, thus changing the appearance of the page later on.

Any help will be most appreciated!

解决方案

I've found what I wanted: http://www.javascriptkit.com/dhtmltutors/externalcss3.shtml .

(Thanks to all who've answered and commented. What I wanted - and finally found, see the link above - was an actual CSS-rule object that I could work with dynamically, like with HTML elements. While some of the answers came close, none of them was exactly it.)

这篇关于如何以编程方式将CSS定义应用于整个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆