放入< div>是不是很糟糕? < head>中的元素标签? [英] Is it bad to put <div> elements within the <head> tags?

查看:84
本文介绍了放入< div>是不是很糟糕? < head>中的元素标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用条件注释使DIV仅出现在使用IE7或更高版本的浏览器中,如下所示:

I want to use conditional comments to make a DIV appear ONLY in browsers with IE7 or older, like this:

<!--[if lt IE 7]>

<div id="browsernotice">
<p>You are using IE7 or less</p>
</div>

<![endif]-->

据我了解,条件注释只能用于标题。

As far as I understand, conditional comments only work in the header.

这是否坏?

我应该使用条件注释来添加一个使不可见DIV 可见性的样式表:可见

Should I rather use conditional comments to instert a stylesheet that makes an invisible DIV visibility:visible?

推荐答案

最好的方法是将内容保留在文档正文中,应用一个样式表为IE来隐藏div。

The best way is to keep the content as is in the document body but instead apply a style sheet for ie that hides the div.

with css

    #browsernotice {
       display:none;
}

用条件语句调用它

And call it with a conditional statement

<!--[if lt IE 7]>
<link href="ie7.css" type="text/css" rel="stylesheet">
<![endif]-->

这篇关于放入&lt; div&gt;是不是很糟糕? &lt; head&gt;中的元素标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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