简体   繁体   English

CSS JavaScript样式表已禁用?

[英]css javascript style sheet disabled?

what does it mean to have a style sheet disabled? 禁用样式表是什么意思?

I just realised that its possible when i visited this page.. https://developer.mozilla.org/en/DOM/HTMLStyleElement 我刚刚访问此页面时才意识到这是可能的。.https ://developer.mozilla.org/en/DOM/HTMLStyleElement

The stylesheet included in the web page would be disabled if the attribute disabled is added in the <link> tag... 如果在<link>标记中添加了disable属性,则将disabled网页中包含的样式表。

This is mostly used when the web pages apply multiple themes...and has something of a sort of a Themeroller 这通常在网页应用多个主题时使用...并且具有某种Themeroller

You can disable styles by setting the disabled property on the element that loaded them (either a style element for inline styles, or a link element for linked stylesheets). 您可以通过在加载style元素上设置disabled属性来禁用样式(对于内联样式,该元素为样式元素,对于链接样式表为link元素)。 When disabled, a stylesheet's rules aren't applied. 禁用时,不会应用样式表的规则。

Example: 例:

CSS: CSS:

<style id='style2'>
  p {
    color: green;
    font-weight: bold;
  }
</style>

HTML: HTML:

<p id ='theParagraph'>Click this paragraph to toggle the <tt>style2</tt> styles.</p>

(I know, I know, tt is deprecated.) (我知道,我知道, tt已过时。)

JavaScript: JavaScript:

document.getElementById('theParagraph').onclick = function() {
  var style = document.getElementById('style2');
  style.disabled = !style.disabled;
};

Live copy 即时复制

It means its style declarations contained within will not be applied. 这意味着将不会应用其中包含的样式声明。

jsFiddle . jsFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM