gpt4 book ai didi

html - 在样式属性中使用导入

转载 作者:行者123 更新时间:2023-11-27 23:56:34 25 4
gpt4 key购买 nike

首先,让我说清楚一点。我说的是在html style=''属性中导入css文件。您可以假设使用Internet Explorer 9。

我不在乎<link>标记或其他导入CSS的方法。

可以说我有一个简单的.css文件:

#inputArea{
width: width:72px;
}


为什么此导入无效?

<input type=text id='inputArea' style="@import url(simple.css);">


什么时候导入有效?

<style>
@import url(simple.css);
</style>


style=""属性何时导入?为什么这个不起作用?

最佳答案

style属性采用declarations列表,并将该列表中的属性专门应用于owner元素。

@import不是声明,并且不适用于特定元素。它只能与组成statements的选择器和其他@构造一起显示在样式表的顶层。

将包含选择其他元素的规则的样式表导入元素的内联样式没有任何意义。就像在说:

<input type=text id='inputArea' style="body { margin: 0 }">


同样没有意义。

关于html - 在样式属性中使用导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56228937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com