@import问题 [英] @import problem

查看:86
本文介绍了@import问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我使用经过验证的XHTML和CSS创建了一个网站。它也可以正常工作。

只有在IE中我看到网站没有CSS(虽然非常快)和

然后CSS用于构建页面。 />

当我使用它时它工作正常:


< link href =" styles / site.css"的rel ="样式表"类型= QUOT;文本/ CSS" />


但是这并不是:


< style type =" text / css" media =" screen"><! - @import" styles / site.css";

- >< / style>


任何人都知道为什么会这样吗?


马克

Hello

I made a site with validated XHTML and CSS. It works fine also.
Only in IE i see the site build up without CSS (very fast though) and
then the CSS is used to build the page.

When i use this it works fine:

<link href="styles/site.css" rel="stylesheet" type="text/css" />

But with this it does not:

<style type="text/css" media="screen"><!-- @import "styles/site.css";
--></style>

Anyone knows why this happens?

Mark

推荐答案

Mark写道:
你好

我用一个经过验证的XHTML和CSS制作了一个网站。它也可以正常工作。
只有在IE中我看到网站没有CSS(虽然非常快)和
然后CSS用于构建页面。

当我使用它它工作正常:

< link href =" styles / site.css"的rel ="样式表"类型= QUOT;文本/ CSS" />

但有了它,它不会:

< style type =" text / css" media =" screen"><! - @import" styles / site.css" ;;
- >< / style>
Hello

I made a site with validated XHTML and CSS. It works fine also.
Only in IE i see the site build up without CSS (very fast though) and
then the CSS is used to build the page.

When i use this it works fine:

<link href="styles/site.css" rel="stylesheet" type="text/css" />

But with this it does not:

<style type="text/css" media="screen"><!-- @import "styles/site.css";
--></style>




因为CSS解释器不知道是什么


<! - @import" styles / site.css" ;; - >


表示。试试


< style type =" text / css" media =" screen"

<! -

@import" styles / site.css" ;;

- >

< / style>


和原版一样,这会将@import指令包装成HMTL

评论所以HTML解释器不知道< STYLE>标签

不要试图将其内容读作HTML。通过这种安排,CSS

翻译不知道是什么


<! -





- >


表示。但是由于@import指令现在已经开始了,所以

解释器将重新开始,考虑到<! - 结束并完成

并且处理@import指令作为新的东西。

或者,您可以免除HTML评论分隔符

理论上没有人再使用CSS盲用户代理。



Because the CSS interpreter doesn''t know what

<!-- @import "styles/site.css"; -->

means. Try

<style type="text/css" media="screen">
<!--
@import "styles/site.css";
-->
</style>

As with your original, this wraps the @import directive into an HMTL
comment so that HTML interpreters that don''t know what the <STYLE> tag
is don''t try to read its content as HTML. With this arrangement, the CSS
interpreter won''t know what either

<!--

or

-->

means. But since the @import directive is now on its own line, the
interpreter will begin afresh, considering the <!-- to be over and done
with and treating the @import directive as something new.
Alternatively, you could dispense with the HTML comment delimiters on
the theory that no one is using CSS-blind user agents any more.


Harlan Messinger写道:
Harlan Messinger wrote:
我创建了一个带有经过验证的XHTML和CSS的网站。
I made a site with validated XHTML and CSS.


尝试

< style type =" text / css" media =" screen"
<! -
@import" styles / site.css";
- >
< / style>

Try

<style type="text/css" media="screen">
<!--
@import "styles/site.css";
-->
</style>




不在XHTML中!


要么:


< style type = "文本/ CSS" media =" screen"

@import" styles / site.css";

< / style>





< style type =" text / css" media =" screen"><! - / * - ><![CDATA [/ *><! - * /

@import" styles / site.css" ;;

/ *]]> * / - ><!]]>< / style>


- -

David Dorward< http://blog.dorward.me.uk/> < http://dorward.me.uk/>

Home是〜/ .bashrc的位置



Not in XHTML!

Either:

<style type="text/css" media="screen">
@import "styles/site.css";
</style>

or

<style type="text/css" media="screen"><!--/*--><![CDATA[/*><!--*/
@import "styles/site.css";
/*]]>*/--><!]]></style>

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is


David Dorward写道:
David Dorward wrote:
Harlan Messinger写道:

Harlan Messinger wrote:

我创建了一个带有经过验证的XHTML和CSS的网站。
I made a site with validated XHTML and CSS.


尝试

< style type =" text / css" media =" screen"
<! -
@import" styles / site.css";
- >
< / style>
Try

<style type="text/css" media="screen">
<!--
@import "styles/site.css";
-->
</style>



不在XHTML中!


Not in XHTML!




糟糕,错过了那一部分。那么,是的,HTML评论分隔符是无意义的 - 任何知道XHTML的东西,知道< STYLE>!不计算下面的

公式,使XHTML在纯HTML浏览器中运行。但是,

粗俗。

要么:

< style type =" text / css" media =" screen"
@import" styles / site.css";
< / style>



< ; style type =" text / css" media =" screen"><! - / * - ><![CDATA [/ *><! - * /
@import" styles / site.css" ;
/ *]]> * / - ><!]]>< / style>



Oops, missed that part. Then, yes, the HTML comment delimiters are
pointless--anything that knows XHTML, knows <STYLE>! Not counting your
formulation below for making XHTML work in HTML-only browsers. How
vulgar, though.

Either:

<style type="text/css" media="screen">
@import "styles/site.css";
</style>

or

<style type="text/css" media="screen"><!--/*--><![CDATA[/*><!--*/
@import "styles/site.css";
/*]]>*/--><!]]></style>



这篇关于@import问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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