<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[阿Tim日志]]></title> 
<link>https://atim.cn/index.php</link> 
<description><![CDATA[专业的php开发者.开发团队的带队人]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[阿Tim日志]]></copyright>
<item>
<link>https://atim.cn/post/305/</link>
<title><![CDATA[什么是CSS hack及写法]]></title> 
<author>bkkkd &lt;partybase@gmail.com&gt;</author>
<category><![CDATA[Web 技术 ]]></category>
<pubDate>Sat, 07 Jul 2007 06:50:42 +0000</pubDate> 
<guid>https://atim.cn/post/305/</guid> 
<description>
<![CDATA[ 
	来源：http://www.div-css.com <br/>什么是CSS hack<br/>由于不同的浏览器，比如Internet Explorer 6,Internet Explorer 7,Mozilla Firefox等，对CSS的解析认识不一样，因此会导致生成的页面效果不一样，得不到我们所需要的页面效果。<br/><br/>这个时候我们就需要针对不同的浏览器去写不同的CSS，让它能够同时兼容不同的浏览器，能在不同的浏览器中也能得到我们想要的页面效果。<br/><br/>这个针对不同的浏览器写不同的CSS code的过程，就叫CSS hack,也叫写CSS hack。<br/><br/>CSS Hack的原理是什么<br/>由于不同的浏览器对CSS的支持及解析结果不一样，还由于CSS中的优先级的关系。我们就可以根据这个来针对不同的浏览器来写不同的CSS。<br/><br/>比如 IE6能识别下划线_和星号*，IE7能识别星号*，当不能识别下划线_，而firefox两个都不能认识。等等<br/><br/>书写顺序，一般是将识别能力强的浏览器的CSS写在后面。下面如何写里面说得更详细些。<br/><br/>如何写CSS Hack<br/>比如要分辨IE6和firefox两种浏览器，可以这样写： <br/><div class="code"><br/>&lt;style&gt; &nbsp; <br/>div&#123; &nbsp; <br/> &nbsp; &nbsp;background:green; /* for firefox */ &nbsp; <br/> &nbsp; &nbsp;*background:red; &nbsp;/* for IE6 */ &nbsp; <br/>&#125; &nbsp; <br/>&lt;/style&gt; &nbsp; <br/><br/>&lt;div&gt;我在IE6中看到是红色的，在firefox中看到是绿色的。&lt;/div&gt; &nbsp;<br/>&lt;style&gt; div&#123; &nbsp; background:green; /* for firefox */ &nbsp; *background:red; &nbsp;/* for IE6 */ &#125; &lt;/style&gt; &lt;div&gt;我在IE6中看到是红色的，在firefox中看到是绿色的。&lt;/div&gt;<br/></div><br/>解释一下：<br/>上面的css在firefox中，它是认识不了后面的那个带星号*的东东是什么的，于是将它过滤掉，不予理睬，解析得到的结果是:div&#123;background:green&#125;,于是理所当然这个div的背景是绿色的。<br/>在IE6中呢，它两个background都能识别出来，它解析得到的结果是:div&#123;background:green;background:red;&#125;,于是根据优先级别，处在后面的red的优先级高，于是当然这个div的背景颜色就是红色的了。<br/><br/><br/><br/> <br/><br/>CSS hack:区分IE6，IE7，firefox区别不同浏览器，CSS hack写法：<br/><br/><br/>区别IE6与FF：<br/> &nbsp; &nbsp; &nbsp; background:orange;*background:blue;<br/><br/><br/>区别IE6与IE7：<br/> &nbsp; &nbsp; &nbsp; background:green !important;background:blue;<br/><br/><br/>区别IE7与FF：<br/> &nbsp; &nbsp; &nbsp; background:orange; *background:green;<br/><br/><br/>区别FF，IE7，IE6：<br/> &nbsp; &nbsp; &nbsp; background:orange;*background:green !important;*background:blue;<br/><br/><br/>注：IE都能识别*;标准浏览器(如FF)不能识别*；<br/>IE6能识别*，但不能识别 !important,<br/>IE7能识别*，也能识别!important;<br/>FF不能识别*，但能识别!important;<br/><a href="https://atim.cn/attachment/1183791030_0.gif" target="_blank"><img src="https://atim.cn/attachment/1183791030_0.gif" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>
]]>
</description>
</item><item>
<link>https://atim.cn/post/305/#blogcomment451</link>
<title><![CDATA[[评论] 什么是CSS hack及写法]]></title> 
<author>lee &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 08 Jul 2007 06:43:03 +0000</pubDate> 
<guid>https://atim.cn/post/305/#blogcomment451</guid> 
<description>
<![CDATA[ 
	忘记了.N年不写
]]>
</description>
</item><item>
<link>https://atim.cn/post/305/#blogcomment452</link>
<title><![CDATA[[评论] 什么是CSS hack及写法]]></title> 
<author>lee &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 11 Jul 2007 00:39:02 +0000</pubDate> 
<guid>https://atim.cn/post/305/#blogcomment452</guid> 
<description>
<![CDATA[ 
	错字,是刚好,不是更好
]]>
</description>
</item>
</channel>
</rss>