CSS 中文开发手册
CSS 中文开发手册
脚本 | @media.scripting (Media Queries) - CSS 中文开发手册
该scripting CSS @media媒体功能可基于脚本(如JavaScript)是否可用来应用样式。
语法
该scripting功能被指定为从下面的列表中选择的关键字值。
none脚本在当前文档中完全不可用。
initial-only在初始页面加载期间启用脚本,但不是之后。
enabled当前文档支持并激活脚本。
例子
HTML
<p class="script-none">You do not have scripting available. :-(</p> <p class="script-initial-only">Your scripting is only enabled during the initial page load. Weird.</p> <p class="script-enabled">You have scripting enabled! :-)</p>
CSS
p { color: lightgray; } @media (scripting: none) { .script-none { color: red; } } @media (scripting: initial-only) { .script-initial-only { color: red; } } @media (scripting: enabled) { .script-enabled { color: red; } }
结果
规范
Specification | Status | Comment |
---|---|---|
Media Queries Level 4The definition of 'scripting' in that specification. | Working Draft | Deferred to Media Queries Level 5. |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | No support1 | No support2 | No support | No support | No support |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | No support | No support | No support | No support | No support |