<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>XO in My Life &#187; hack</title>
	<atom:link href="http://www.xoboy.net/wpblog/tag/hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xoboy.net/wpblog</link>
	<description></description>
	<lastBuildDate>Fri, 30 Jul 2010 04:51:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>再谈IE的hack</title>
		<link>http://www.xoboy.net/wpblog/ie-hack-again/</link>
		<comments>http://www.xoboy.net/wpblog/ie-hack-again/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 06:17:23 +0000</pubDate>
		<dc:creator>xoboy</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[兼容]]></category>
		<category><![CDATA[浏览器]]></category>

		<guid isPermaLink="false">http://www.xoboy.net/wpblog/?p=73</guid>
		<description><![CDATA[最近频频接触CSS，对不同浏览器的显示效果不同很纠结。现再收集一下关于IE的hack。
1. 区别FF和IE
1-1
首先，当然是!important大法，可以提升指定样式规则的应用优先权，如下面的例子：
插入代码：
div{
background-color: red !important;
background-color: blue;
}
因为!important声明在IE6中并不是绝对的，它会被之后的同名属性定义所替换。也就是说在上面的例子中，IE6所应用的是最后一个背景色的值，即“blue”；而在FF中背景色的值为“red”。
1-2
还有一种方法，就是IE浏览器可以识别“&#62;”等一些符号，如“~”、“`”、“
插入代码：
div{
background-color: red;
&#62;background-color: blue;
}
在FF中得到的是背景色红色，而在IE中得到的背景色是蓝色，根据样式重定义的规则，如果浏览器可以识别“&#62;”，则应该得到的蓝色的背景，因此可以知道“&#62;”只有IE可以识别。
这样，我们就可以把FF和IE的样式分离开。下面就是解决IE自己的问题了。
2. 区别IE5.5和IE的其他版本
看一个例子：
插入代码：
div{
&#62;background-color: black;
&#62;background-color /*IE5.5*/: green;
}
这个例子使用了“&#62;”，只有IE可以识别，在IE6中得到了黑色的背景；而在IE5.5中得到的绿色的背景；在IE5中也得到了黑色的背景。这就说明了第二句定义只有IE5.5能识别，这是个很早就公布的HACK，可以在网上找到相关的资料，要注意的就是在属性名之后是有一个空格的。
到此我们已经把FF、IE5.5、IE6分离出来了，那IE5呢？其实现在我们只要把IE5跟IE6分开就OK了。
3. 区别IE5与IE5.5+
插入代码：
div{
&#62;background-color: red;
}
div/*IE5.5+*/{
&#62;background-color: black;
}
这里我们又用到一个HACK，就是“div/**/{}”，这个定义在IE5以上的版本才能识别出来。这个例子得到的结果是，在IE5中的背景色为红色；在IE5以上版本中得到的是黑色背景。
4. 完整的Hack
这样我们就可以为不同的浏览器定义不同的样式了。来看个完整的例子：
插入代码：
div{
width: 500px;
height: 50px;
background-color: red !important;/*FF*/
background-color: blue;/*IE5*/
text-align:center;
}
div/*IE5.5+*/{
&#62;/*IE only*/background-color: black;/*IE6*/
&#62;/*IE only*/background-color /*IE5.5*/: green;
}
需要注意的是，在上面例子中“background-color”定义的顺利不能改变，即FF-IE5-IE6-IE5.5。对于IE的定义在属性前要加“&#62;”，因为“div/**/{}”这个HACK在FF中可以识别。
#hackme{
/*style for all browser here*/
}
* html #hackme{
/*style for ie here*/
}
下面是一个ie6 png hack，用于内联css
height:20px; /*For Firefox*/
*height:25px; /*For IE7 &#38; IE6*/
_height:20px; /*For IE6*/
IE7的hack
IE7 修复了很多 bug，也增加了对一些选择符的支持，所以现在诸如 *html {} 和 html&#62;body {} 等针对 IE 隐藏或显示的 hack]]></description>
			<content:encoded><![CDATA[<p>最近频频接触CSS，对不同浏览器的显示效果不同很纠结。现再收集一下关于IE的hack。</p>
<p>1. 区别FF和IE<br />
1-1<br />
首先，当然是!important大法，可以提升指定样式规则的应用优先权，如下面的例子：<br />
插入代码：<br />
div{<br />
background-color: red !important;<br />
background-color: blue;<br />
}<br />
因为!important声明在IE6中并不是绝对的，它会被之后的同名属性定义所替换。也就是说在上面的例子中，IE6所应用的是最后一个背景色的值，即“blue”；而在FF中背景色的值为“red”。<br />
<span id="more-73"></span>1-2<br />
还有一种方法，就是IE浏览器可以识别“&gt;”等一些符号，如“~”、“`”、“<br />
插入代码：<br />
div{<br />
background-color: red;<br />
&gt;background-color: blue;<br />
}<br />
在FF中得到的是背景色红色，而在IE中得到的背景色是蓝色，根据样式重定义的规则，如果浏览器可以识别“&gt;”，则应该得到的蓝色的背景，因此可以知道“&gt;”只有IE可以识别。<br />
这样，我们就可以把FF和IE的样式分离开。下面就是解决IE自己的问题了。<br />
2. 区别IE5.5和IE的其他版本<br />
看一个例子：<br />
插入代码：<br />
div{<br />
&gt;background-color: black;<br />
&gt;background-color /*IE5.5*/: green;<br />
}<br />
这个例子使用了“&gt;”，只有IE可以识别，在IE6中得到了黑色的背景；而在IE5.5中得到的绿色的背景；在IE5中也得到了黑色的背景。这就说明了第二句定义只有IE5.5能识别，这是个很早就公布的HACK，可以在网上找到相关的资料，要注意的就是在属性名之后是有一个空格的。<br />
到此我们已经把FF、IE5.5、IE6分离出来了，那IE5呢？其实现在我们只要把IE5跟IE6分开就OK了。<br />
3. 区别IE5与IE5.5+<br />
插入代码：<br />
div{<br />
&gt;background-color: red;<br />
}<br />
div/*IE5.5+*/{<br />
&gt;background-color: black;<br />
}<br />
这里我们又用到一个HACK，就是“div/**/{}”，这个定义在IE5以上的版本才能识别出来。这个例子得到的结果是，在IE5中的背景色为红色；在IE5以上版本中得到的是黑色背景。<br />
4. 完整的Hack<br />
这样我们就可以为不同的浏览器定义不同的样式了。来看个完整的例子：<br />
插入代码：<br />
div{<br />
width: 500px;<br />
height: 50px;<br />
background-color: red !important;/*FF*/<br />
background-color: blue;/*IE5*/<br />
text-align:center;<br />
}<br />
div/*IE5.5+*/{<br />
&gt;/*IE only*/background-color: black;/*IE6*/<br />
&gt;/*IE only*/background-color /*IE5.5*/: green;<br />
}<br />
需要注意的是，在上面例子中“background-color”定义的顺利不能改变，即FF-IE5-IE6-IE5.5。对于IE的定义在属性前要加“&gt;”，因为“div/**/{}”这个HACK在FF中可以识别。</p>
<p>#hackme{<br />
/*style for all browser here*/<br />
}</p>
<p>* html #hackme{<br />
/*style for ie here*/<br />
}</p>
<p>下面是一个ie6 png hack，用于内联css</p>
<p>height:20px; /*For Firefox*/<br />
*height:25px; /*For IE7 &amp; IE6*/<br />
_height:20px; /*For IE6*/</p>
<p>IE7的hack<br />
IE7 修复了很多 bug，也增加了对一些选择符的支持，所以现在诸如 *html {} 和 html&gt;body {} 等针对 IE 隐藏或显示的 hack 都会在 IE7 中失效。虽然 CSS Hack 不推荐使用，条件注释才是万无一失的过滤器，但是条件注释只能出现在 HTML 中，CSS Hack 还是有用武之地的。Nanobot 发现了一些针对 IE7 的 CSS Hack，具体就是：</p>
<p>&gt;body<br />
html*<br />
*+html</p>
<p>这三种写法，其中前两种都是不合法的 CSS 写法，在标准兼容浏览器中被被忽略，但是 IE7 却不这么认为。对于 &gt;body ，它会将缺失的选择符用全局选择符 * 代替，也就是将其处理成了 *&gt;body，而且不光对于 &gt; 选择符，+,~ 选择符中这个现象也存在。对于 html* ，由于 html 和 * 之间没有空格，所以也是一种 CSS 语法错误，但 IE7 不会忽略，而是错误地认为这里有一个空格。对于第三种 *+html，IE7 认为 html 前面的 DTD 声明也是一个元素，所以 html 会被选中，这三种方法中只有这一种方法是合法的 CSS 写法，也就是说可以通过校验器的验证，因此也是作者推荐的 hack 用法。<br />
IE 6 and below<br />
Use * html {} to select the html element.<br />
IE 7 and below<br />
Use *+html, * html {} to select the html element.<br />
IE 7 only<br />
Use *+html {} to select the html element.<br />
IE 7 and modern browsers only<br />
Use html&gt;body {} to select the body element.<br />
Modern browsers only (not IE 7)<br />
Use html&gt;/**/body {} to select the body element.<br />
IE的if条件Hack</p>
<p>&lt;!&#8211;[if IE]&gt; Only IE &lt;![endif]&#8211;&gt;<br />
所有的IE可识别<br />
&lt;!&#8211;[if IE 5.0]&gt; Only IE 5.0 &lt;![endif]&#8211;&gt;<br />
只有IE5.0可以识别<br />
&lt;!&#8211;[if gt IE 5.0]&gt; Only IE 5.0+ &lt;![endif]&#8211;&gt;<br />
IE5.0包换IE5.5都可以识别<br />
&lt;!&#8211;[if lt IE 6]&gt; Only IE 6- &lt;![endif]&#8211;&gt;<br />
仅IE6可识别<br />
&lt;!&#8211;[if gte IE 6]&gt; Only IE 6/+ &lt;![endif]&#8211;&gt;<br />
IE6以及IE6以下的IE5.x都可识别<br />
&lt;!&#8211;[if lte IE 7]&gt; Only IE 7/- &lt;![endif]&#8211;&gt;<br />
仅IE7可识别</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xoboy.net/wpblog/ie-hack-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>补充说明图片垂直居中的问题</title>
		<link>http://www.xoboy.net/wpblog/image-vertical-align/</link>
		<comments>http://www.xoboy.net/wpblog/image-vertical-align/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 05:03:23 +0000</pubDate>
		<dc:creator>xoboy</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[浏览器]]></category>

		<guid isPermaLink="false">http://www.xoboy.net/wpblog/?p=71</guid>
		<description><![CDATA[由于IE与Firefox对CSS的解释不同，往往让我们在对一个图片处于一个div内垂直居中的问题伤透脑筋。上一篇讲述到用top:50%的方法，现在再展开补充说明一下。
首先我们定义一个放置图片的容器
.box{width:600px; height:300px; display:table; border:1px solid #000; background-color:#CCCCCC;}
为了更清楚看到效果，我定义了这个box的边框和背景色。
然后我们在这个容器内再多放置一个
.imgbox {display:table-cell; vertical-align:middle; text-align:center;}
由于IE不支持CSS2中的display:table和display:table-cell，而对于能解释这两个属性的浏览器来说，做到垂直局中到这里就已经足够了。因此我们要针对IE再下点功夫。对htm我们可以这样写：
&#60;div class=&#8221;box&#8221;&#62;
　&#60;div class=&#8221;imgbox&#8221;&#62;&#60;p&#62;&#60;img src=&#8221;图片的位置&#8221; /&#62;&#60;/p&#62;&#60;/div&#62;
&#60;/div&#62;
然后针对IE我们补充hack的内容：
.box {*position:relative;}
.imgbox {*width:100%;*position:absolute; *top:50%; *left:0;}
　.imgbox p {*position: relative; *top:-50%; *margin:0; *padding:0;}
　.imgbox img{ *margin-top:4px;}
对IE来说，用了绝对定位和相对定位，通过两次50%的偏移找到了图片所在div的中心，因此完整的CSS应该为：
.box { width:600px; height:300px; display:table; border:1px solid #000; background-color:#CCCCCC; *position:relative;} /*这个层的长宽可以自定义*/
.imgbox { display:table-cell; vertical-align:middle; text-align:center; *width:100%; *position:absolute;  *top:50%; *left:0;}
　.imgbox p {*position: relative; *top:-50%; *margin:0; *padding:0;}
　.imgbox img{ *margin-top:4px;}
大功告成！
]]></description>
			<content:encoded><![CDATA[<p>由于IE与Firefox对CSS的解释不同，往往让我们在对一个图片处于一个div内垂直居中的问题伤透脑筋。上一篇讲述到用top:50%的方法，现在再展开补充说明一下。</p>
<p><span id="more-71"></span>首先我们定义一个放置图片的容器</p>
<p>.box{width:600px; height:300px; display:table; border:1px solid #000; background-color:#CCCCCC;}</p>
<p>为了更清楚看到效果，我定义了这个box的边框和背景色。</p>
<p>然后我们在这个容器内再多放置一个</p>
<p>.imgbox {display:table-cell; vertical-align:middle; text-align:center;}</p>
<p>由于IE不支持CSS2中的display:table和display:table-cell，而对于能解释这两个属性的浏览器来说，做到垂直局中到这里就已经足够了。因此我们要针对IE再下点功夫。对htm我们可以这样写：</p>
<p>&lt;div class=&#8221;box&#8221;&gt;<br />
　&lt;div class=&#8221;imgbox&#8221;&gt;&lt;p&gt;&lt;img src=&#8221;图片的位置&#8221; /&gt;&lt;/p&gt;&lt;/div&gt;<br />
&lt;/div&gt;</p>
<p>然后针对IE我们补充hack的内容：</p>
<p>.box {*position:relative;}<br />
.imgbox {*width:100%;*position:absolute; *top:50%; *left:0;}<br />
　.imgbox p {*position: relative; *top:-50%; *margin:0; *padding:0;}<br />
　.imgbox img{ *margin-top:4px;}</p>
<p>对IE来说，用了绝对定位和相对定位，通过两次50%的偏移找到了图片所在div的中心，因此完整的CSS应该为：</p>
<p>.box { width:600px; height:300px; display:table; border:1px solid #000; background-color:#CCCCCC; *position:relative;} /*这个层的长宽可以自定义*/<br />
.imgbox { display:table-cell; vertical-align:middle; text-align:center; *width:100%; *position:absolute;  *top:50%; *left:0;}<br />
　.imgbox p {*position: relative; *top:-50%; *margin:0; *padding:0;}<br />
　.imgbox img{ *margin-top:4px;}</p>
<p>大功告成！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xoboy.net/wpblog/image-vertical-align/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>简单而实用的CSS属性：min-height</title>
		<link>http://www.xoboy.net/wpblog/css-min-height/</link>
		<comments>http://www.xoboy.net/wpblog/css-min-height/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 08:07:42 +0000</pubDate>
		<dc:creator>xoboy</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[IE6]]></category>

		<guid isPermaLink="false">http://www.xoboy.net/wpblog/?p=68</guid>
		<description><![CDATA[今天讲解一下一个简单而实用的CSS属性：min-height，它允许你指定元素的最小高度，在需要平衡布局时非常有用。看看下面的图解就一目了然了。
 
一般写法：
.with_minheight {
　　min-height: 550px;
}
但需要注意的是，IE6不支持min-height（又一个要杀死IE6的理由），但是有一个min-height hack的写法：
 .with_minheight {
　　min-height:550px;
　　height:auto !important;
　　height:550px;
}
以后在进行多栏式的布局时可以用这个属性控制美观度:coolsmile:
]]></description>
			<content:encoded><![CDATA[<p>今天讲解一下一个简单而实用的CSS属性：min-height，它允许你指定元素的最小高度，在需要平衡布局时非常有用。看看下面的图解就一目了然了。<span id="more-68"></span></p>
<p><img src="http://uh.9ria.com/attachment/200912/9/7297_12603705123hSH.gif" alt="" width="470" height="270" /> </p>
<p>一般写法：</p>
<p>.with_minheight {<br />
　　min-height: 550px;<br />
}</p>
<p>但需要注意的是，IE6不支持min-height（又一个要杀死IE6的理由），但是有一个min-height hack的写法：</p>
<p> .with_minheight {<br />
　　min-height:550px;<br />
　　height:auto !important;<br />
　　height:550px;<br />
}</p>
<p>以后在进行多栏式的布局时可以用这个属性控制美观度:coolsmile:</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xoboy.net/wpblog/css-min-height/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>什么是CSS hack</title>
		<link>http://www.xoboy.net/wpblog/what_is_css_hack/</link>
		<comments>http://www.xoboy.net/wpblog/what_is_css_hack/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 03:44:28 +0000</pubDate>
		<dc:creator>xoboy</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[兼容]]></category>
		<category><![CDATA[浏览器]]></category>

		<guid isPermaLink="false">http://www.xoboy.net/wpblog/?p=64</guid>
		<description><![CDATA[由于不同的浏览器，比如Internet Explorer 6,Internet Explorer 7,Mozilla Firefox等，对CSS的解析认识不一样，因此会导致生成的页面效果不一样，得不到我们所需要的页面效果。
这个时候我们就需要针对不同的浏览器去写不同的CSS，让它能够同时兼容不同的浏览器，能在不同的浏览器中也能得到我们想要的页面效果。
这个针对不同的浏览器写不同的CSS code的过程，就叫CSS hack,也叫写CSS hack。
CSS Hack的原理是什么
由于不同的浏览器对CSS的支持及解析结果不一样，还由于CSS中的优先级的关系。我们就可以根据这个来针对不同的浏览器来写不同的CSS。
比如 IE6能识别下划线_和星号*，IE7能识别星号*，当不能识别下划线_，而firefox两个都不能认识。等等
书写顺序，一般是将识别能力强的浏览器的CSS写在后面。下面如何写里面说得更详细些。
如何写CSS Hack
比如要分辨IE6和firefox两种浏览器，可以这样写：
&#60;style&#62;   
div{   
background:green; /* for firefox */   
*background:red; /* for IE6 */   
}   
&#60;/style&#62;   
&#60;div&#62;我在IE6中看到是红色的，在firefox中看到是绿色的。&#60;/div&#62;
&#60;style&#62;
div{
background:green; /* for firefox */
*background:red; /* for IE6 */
}
&#60;/style&#62;
&#60;div&#62;我在IE6中看到是红色的，在firefox中看到是绿色的。&#60;/div&#62;
解释一下：

上面的css在firefox中，它是认识不了后面的那个带星号*的东东是什么的，于是将它过滤掉，不予理睬，解析得到的结果是:div{background:green},于是理所当然这个div的背景是绿色的。
 
在IE6中呢，它两个background都能识别出来，它解析得到的结果是:div{background:green;background:red;},于是根据优先级别，处在后面的red的优先级高，于是当然这个div的背景颜色就是红色的了。
CSS hack:区分IE6，IE7，firefox区别不同浏览器，CSS hack写法：
区别IE6与FF：
background:orange;*background:blue;
background:orange;*background:blue;
区别IE6与IE7：
background:green !important;background:blue;
background:green !important;background:blue;
区别IE7与FF：
background:orange; *background:green;
background:orange; *background:green;
区别FF，IE7，IE6：
background:orange;*background:green !important;*background:blue;
background:orange;*background:green !important;*background:blue;
注：IE都能识别*;标准浏览器(如FF)不能识别*；

IE6能识别*，但不能识别 !important,
IE7能识别*，也能识别!important;
FF不能识别*，但能识别!important;




 
IE6
IE7
FF


*
  √
  √
 ×


!important
  ×
  √
 √



另外再补充一个，下划线”_”, IE6支持下划线，IE7和firefox均不支持下划线。
于是大家还可以这样来区分IE6，IE7，firefox
div{: background:orange;  
*background:green;  
_background:blue;}
div{: background:orange;
*background:green;
_background:blue;}
注：不管是什么方法，书写的顺序都是firefox的写在前面，IE7的写在中间，IE6的写在最后面
付:CSS hack 列表图
]]></description>
			<content:encoded><![CDATA[<p>由于不同的浏览器，比如Internet Explorer 6,Internet Explorer 7,Mozilla Firefox等，对CSS的解析认识不一样，因此会导致生成的页面效果不一样，得不到我们所需要的页面效果。</p>
<p>这个时候我们就需要针对不同的浏览器去写不同的CSS，让它能够同时兼容不同的浏览器，能在不同的浏览器中也能得到我们想要的页面效果。</p>
<p>这个针对不同的浏览器写不同的CSS code的过程，就叫CSS hack,也叫写CSS hack。</p>
<h3>CSS Hack的原理是什么</h3>
<p>由于不同的浏览器对CSS的支持及解析结果不一样，还由于CSS中的优先级的关系。我们就可以根据这个来针对不同的浏览器来写不同的CSS。</p>
<p><span id="more-64"></span>比如 IE6能识别下划线_和星号*，IE7能识别星号*，当不能识别下划线_，而firefox两个都不能认识。等等</p>
<p>书写顺序，一般是将识别能力强的浏览器的CSS写在后面。下面如何写里面说得更详细些。</p>
<h3>如何写CSS Hack</h3>
<p>比如要分辨IE6和firefox两种浏览器，可以这样写：</p>
<p class="code">&lt;style&gt;   <br />
div{   <br />
background:green; /* for firefox */   <br />
*background:red; /* for IE6 */   <br />
}   <br />
&lt;/style&gt;   <br />
&lt;div&gt;我在IE6中看到是红色的，在firefox中看到是绿色的。&lt;/div&gt;<br />
&lt;style&gt;<br />
div{<br />
background:green; /* for firefox */<br />
*background:red; /* for IE6 */<br />
}<br />
&lt;/style&gt;<br />
&lt;div&gt;我在IE6中看到是红色的，在firefox中看到是绿色的。&lt;/div&gt;</p>
<p><strong>解释一下：<br />
</strong><br />
上面的css在firefox中，它是认识不了后面的那个带星号*的东东是什么的，于是将它过滤掉，不予理睬，解析得到的结果是:div{background:green},于是理所当然这个div的背景是绿色的。</p>
<p> </p>
<p>在IE6中呢，它两个background都能识别出来，它解析得到的结果是:div{background:green;background:red;},于是根据优先级别，处在后面的red的优先级高，于是当然这个div的背景颜色就是红色的了。</p>
<p>CSS hack:区分IE6，IE7，firefox区别不同浏览器，CSS hack写法：</p>
<p>区别IE6与FF：</p>
<p class="code">background:orange;*background:blue;<br />
background:orange;*background:blue;</p>
<p>区别IE6与IE7：</p>
<p class="code">background:green !important;background:blue;<br />
background:green !important;background:blue;</p>
<p>区别IE7与FF：</p>
<p class="code">background:orange; *background:green;<br />
background:orange; *background:green;</p>
<p>区别FF，IE7，IE6：</p>
<p class="code">background:orange;*background:green !important;*background:blue;<br />
background:orange;*background:green !important;*background:blue;</p>
<p>注：IE都能识别*;标准浏览器(如FF)不能识别*；</p>
<ul>
<li>IE6能识别*，但不能识别 !important,</li>
<li>IE7能识别*，也能识别!important;</li>
<li>FF不能识别*，但能识别!important;</li>
</ul>
<table border="0">
<tbody>
<tr>
<th> </th>
<th>IE6</th>
<th>IE7</th>
<th>FF</th>
</tr>
<tr>
<td>*</td>
<td>  √</td>
<td>  √</td>
<td> ×</td>
</tr>
<tr>
<td>!important</td>
<td>  ×</td>
<td>  √</td>
<td> √</td>
</tr>
</tbody>
</table>
<p>另外再补充一个，下划线”_”, IE6支持下划线，IE7和firefox均不支持下划线。</p>
<p>于是大家还可以这样来区分IE6，IE7，firefox</p>
<p class="code">div{: background:orange;  <br />
*background:green;  <br />
_background:blue;}<br />
div{: background:orange;<br />
*background:green;<br />
_background:blue;}</p>
<p>注：不管是什么方法，书写的顺序都是firefox的写在前面，IE7的写在中间，IE6的写在最后面</p>
<p>付:<a href="http://www.xoboy.net/wpblog/wp-content/uploads/2009/08/css_buglist.gif" target="_blank">CSS hack 列表图</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xoboy.net/wpblog/what_is_css_hack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
