gpt4 book ai didi

html - 为样式表创建有效的条件注释,没有 'bogus comment' 验证器错误

转载 作者:搜寻专家 更新时间:2023-10-31 08:06:08 24 4
gpt4 key购买 nike

我的 head 标签中有以下内容:

<link rel="stylesheet" href="Scripts/styleMain.css" media="all" type="text/css" />
<![if gte IE 9]><!-->
<link rel="stylesheet" href="Scripts/styleMob.css" media="screen and (max-width:500px)" type="text/css" />
<link rel="stylesheet" href="Scripts/styleDes.css" media="screen and (min-width:501px)" type="text/css" />
<!--<![endif]-->
<!--[if lt IE 9]>
<link rel="stylesheet" href="styleDes.css" type="text/css" />
<![endif]-->

问题是,第二行被认为是虚假评论,同一行的第二个标签被认为是评论的过早结束。

在同一行和第一个 endif 上有额外的标签只会给我两个虚假的评论错误。

有什么方法可以让我的样式表带有条件,并让它们验证吗?还是我注定要使用无效代码来干扰我的强制症编码?

最佳答案

你的第二行有错误的开始评论定界符:

<!--[if gte IE 9]><!-->

请注意此处的语法高亮显示,它现在作为注释正确高亮显示。

后面的其余标记也将正确突出显示,因为 <!-->现在被视为 <!其次是 --> , 而不是 <!--其次是 >因为它会出现在您的无效标记中:

<link rel="stylesheet" href="Scripts/styleMain.css" media="all" type="text/css" />
<!--[if gte IE 9]><!-->
<link rel="stylesheet" href="Scripts/styleMob.css" media="screen and (max-width:500px)" type="text/css" />
<link rel="stylesheet" href="Scripts/styleDes.css" media="screen and (min-width:501px)" type="text/css" />
<!--<![endif]-->
<!--[if lt IE 9]>
<link rel="stylesheet" href="styleDes.css" type="text/css" />
<![endif]-->

您的代码中没有突出显示为注释的部分将是 IE9 及更高版本以及其他浏览器如何查看您的标记。较旧的 IE 只会看到您的第一个和最后一个 <link>元素。

关于html - 为样式表创建有效的条件注释,没有 'bogus comment' 验证器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17490727/

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