[英]Using import within a style attribute
First let me be perfectly clear. 首先,让我说清楚一点。 I am talking about importing a css file within a html
style=''
attribute. 我正在谈论在html
style=''
属性中导入css文件。 You can assume Internet Explorer 9. 您可以假设使用Internet Explorer 9。
I DON'T CARE ABOUT <link>
TAGS or other methods of importing css. 我不在乎
<link>
标记或其他导入CSS的方法。
Lets say I have a simple .css file: 可以说我有一个简单的.css文件:
#inputArea{
width: width:72px;
}
Why is this import not working? 为什么此导入无效?
<input type=text id='inputArea' style="@import url(simple.css);">
When this import does work? 什么时候导入有效?
<style>
@import url(simple.css);
</style>
When does a style=""
attribute import work? 何时导入
style=""
属性? Why isn't this one working? 为什么这个不起作用?
The style
attribute takes a list of declarations , and applies properties from that list specifically to the owner element. style
属性采用一个声明列表,并将该列表中的属性专门应用于owner元素。
@import
is not a declaration and does not apply to a particular element. @import
不是声明,并且不适用于特定元素。 It can only appear in the top level of a style sheet along with the selectors and other @
-constructs that comprise the statements . 它只能与组成语句的选择器和其他
@
-constructs一起出现在样式表的顶层。
It doesn't make any sense to import a stylesheet, that contains rules selecting other elements, into an element's inline style. 将包含选择其他元素的规则的样式表导入元素的内联样式没有任何意义。 It's like saying:
就像在说:
<input type=text id='inputArea' style="body { margin: 0 }">
which is just as meaningless. 同样没有意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.