<?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>一起CSS &#187; IE6</title>
	<atom:link href="http://www.17css.com/tag/ie6/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.17css.com</link>
	<description>一起CSS，专注、关注CSS等前端技术。</description>
	<lastBuildDate>Tue, 27 Jul 2010 00:58:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>隐藏域在ie中占空间的bug</title>
		<link>http://www.17css.com/ie-input-hidden-bug/</link>
		<comments>http://www.17css.com/ie-input-hidden-bug/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 08:32:39 +0000</pubDate>
		<dc:creator>青色</dc:creator>
				<category><![CDATA[前端技术]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[IE7]]></category>

		<guid isPermaLink="false">http://www.17css.com/?p=723</guid>
		<description><![CDATA[input 的 type 设为 hidden 的话，就是隐藏域（废话）。隐藏域在页面中不显示，但可以有值。既然是&#8220;隐藏&#8221;的，怎么还说会占空间呢。这是 IE 的 bug，不过这个 bug 的出现需要一定的条件，... ]]></description>
			<content:encoded><![CDATA[<p>input 的 type 设为 hidden 的话，就是隐藏域（废话）。隐藏域在页面中不显示，但可以有值。既然是&ldquo;隐藏&rdquo;的，怎么还说会占空间呢。这是 <a href="http://www.17css.com/tag/IE/" title="查看关于 IE 的全部文章">IE</a> 的 <a href="http://www.17css.com/tag/bug/" title="查看关于 bug 的全部文章">bug</a>，不过这个 <a href="http://www.17css.com/tag/bug/" title="查看关于 bug 的全部文章">bug</a> 的出现需要一定的条件，换句话说就是出现的几率比较低，所以可能很多人没有遇到过。那什么样的情况下会出现呢？看下面的代码：</p>
<pre class="prettyprint">
&lt;input /&gt;
&lt;input class=&quot;hide&quot; type=&quot;hidden&quot; /&gt;
&lt;input class=&quot;hide&quot; type=&quot;hidden&quot; /&gt;
&hellip;&hellip;（省略 8 个或更多）
&lt;input type=&quot;submit&quot; value=&quot;send&quot; /&gt;</pre>
<p>这样的代码出现的几率是比较小吧，一般情况下，不会有这么多隐藏域，而且表单标签可能会有其他如 p、li 等标签包裹，这样的话，此 <a href="http://www.17css.com/tag/bug/" title="查看关于 bug 的全部文章">bug</a> 又不会出现。我们抛开这些情况，以此 <a href="http://www.17css.com/tag/bug/" title="查看关于 bug 的全部文章">bug</a> 会出现来讨论。上面代码运行后在 <a href="http://www.17css.com/tag/IE6/" title="查看关于 IE6 的全部文章">IE6</a> 或 <a href="http://www.17css.com/tag/IE7/" title="查看关于 IE7 的全部文章">IE7</a> 和 <a href="http://www.17css.com/tag/Firefox/" title="查看关于 Firefox 的全部文章">FF</a> 中的效果如下图：</p>
<p><img alt="隐藏域在 ie 中占空间的示例图片" src="http://www.17css.com/works/10/C/images/input-hidden.png" /></p>
<p>在 <a href="http://www.17css.com/tag/IE6/" title="查看关于 IE6 的全部文章">IE6</a> 或 <a href="http://www.17css.com/tag/IE7/" title="查看关于 IE7 的全部文章">IE7</a> 中，输入框和提交按钮有很大的间隔，而在 <a href="http://www.17css.com/tag/Firefox/" title="查看关于 Firefox 的全部文章">FF</a> 中则效果正常。如果隐藏域越多的话，<a href="http://www.17css.com/tag/IE6/" title="查看关于 IE6 的全部文章">IE6</a> 或 <a href="http://www.17css.com/tag/IE7/" title="查看关于 IE7 的全部文章">IE7</a> 中间隔就越大，而 <a href="http://www.17css.com/tag/Firefox/" title="查看关于 Firefox 的全部文章">FF</a> 中则始终没有问题。你可以 <a title="查看 隐藏域在ie中占空间的bug实例" href="http://www.17css.com/works/10/C/input-hidden.html">查看Demo</a></p>
<p><span id="more-723"></span></p>
<p>解决此 <a href="http://www.17css.com/tag/bug/" title="查看关于 bug 的全部文章">bug</a> 有以下几个办法：</p>
<dl>
<dt>把所有隐藏域写在同一行里</dt>
<dd>优点：不要借助其他标签，不要写样式</dd>
<dd>缺点：代码可读性下降</dd>
<dt>隐藏域浮动</dt>
<dd>优点：代码可读性好</dd>
<dd>缺点：需要借助 class，如果使用属性选择器的话，<a href="http://www.17css.com/tag/IE6/" title="查看关于 IE6 的全部文章">IE6</a> 不支持</dd>
<dt>隐藏域绝对定位</dt>
<dd>优点：代码可读性好</dd>
<dd>缺点：需要借助 class，如果使用属性选择器的话，<a href="http://www.17css.com/tag/IE6/" title="查看关于 IE6 的全部文章">IE6</a> 不支持</dd>
</dl>
<p>其实并不只是隐藏域会占空间，把 type 换成其他类型，同样会有这样的问题。比如把 type 换成 button，然后 display:none，效果是一样的。</p>
<p>上面的几种方法虽然可以解决这个问题，但个人认为都不是很完美，如果你有更好的办法，欢迎留言。</p>
<p>&copy;2010 <a href="http://www.17css.com">一起CSS</a>. All Rights Reserved.</p>.<h2  class="related_post_title">相关日志</h2><ul class="related_post"><li><a href="http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/" title="纯css下拉菜单详解">纯css下拉菜单详解</a> (12)</li><li><a href="http://www.17css.com/hover-of-the-bug-in-ie6/" title=":hover伪类在IE6中的BUG">:hover伪类在IE6中的BUG</a> (3)</li><li><a href="http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/" title="IE6支持PNG透明(alpha通道)的4种方法">IE6支持PNG透明(alpha通道)的4种方法</a> (7)</li><li><a href="http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/" title="别说IE6不认识!important">别说IE6不认识!important</a> (5)</li><li><a href="http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/" title="css2高级选择器">css2高级选择器</a> (4)</li><li><a href="http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/" title="IE6双倍margin bug">IE6双倍margin bug</a> (1)</li><li><a href="http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/" title="如何在IE6里定义高度小于18px的盒子">如何在IE6里定义高度小于18px的盒子</a> (0)</li><li><a href="http://www.17css.com/ie6-max-height/" title="让IE6也有最大高度max-height的效果">让IE6也有最大高度max-height的效果</a> (7)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.17css.com/ie-input-hidden-bug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IE6支持PNG透明(alpha通道)的4种方法</title>
		<link>http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/</link>
		<comments>http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 14:32:24 +0000</pubDate>
		<dc:creator>青色</dc:creator>
				<category><![CDATA[前端技术]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[不透明]]></category>

		<guid isPermaLink="false">http://www.17css.com/?p=308</guid>
		<description><![CDATA[想特别说明一下，IE6与生俱来就支持png8的索引色透明度，但不支持png的 alpha 透明度。而我们一直要解决的是让IE6支持PNG的 alpha 透明度。下面我收集整理了4种方法，但都是以滤镜、Js、css 等作... ]]></description>
			<content:encoded><![CDATA[<p>想特别说明一下，IE6与生俱来就支持png8的索引色透明度，但不支持png的 alpha 透明度。而我们一直要解决的是让IE6支持PNG的 alpha 透明度。下面我收集整理了4种方法，但都是以滤镜、Js、css 等作为基础模拟还原效果，虽然没有真正的解决alpha透明度问题，但也总算解决了燃眉之急。</p>
<h4>IE6支持png8透明:</h4>
<p>IE6与生俱来就支持png8的索引色透明度，但不支持png或8位以上的 alpha 透明度。而对于非动画的GIF建议你使用PNG8，因为体积会更小。  测试实例：<a href="http://blog.gulu77.com/demo/200809/test_IE6png8/">http://blog.gulu77.com/demo/200809/test_IE6png8/</a></p>
<h4>1、AlphaImageLoader 筛选器</h4>
<p>使用简介：在每个标签样式中插入：  filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=&rsquo;image.png&rsquo;, sizingMethod=&rsquo;scale&rsquo;)  官方原文：http://support.microsoft.com/kb/294714/zh-cn <a href="http://support.microsoft.com/kb/294714/zh-cn">go</a>  测试实例：<a href="http://blog.gulu77.com/demo/200809/test_AlphaImageLoader/">http://blog.gulu77.com/demo/200809/test_AlphaImageLoader/</a></p>
<h4>2、PNG Transparency in IE</h4>
<p>使用简介：相对来说比较简洁，使用一段包含滤镜的JavaScript 就可以模拟图片或背景 PNG alpha 透明度。  官方原文：http://codingforums.com/archive/index.php?t-80555.html <a href="http://codingforums.com/archive/index.php?t-80555.html">go</a>  测试实例：<a href="http://blog.gulu77.com/demo/200809/test_PNGTransparncyinIE/">http://blog.gulu77.com/demo/200809/test_PNGTransparncyinIE/</a></p>
<p><span id="more-308"></span></p>
<h4>3、IE PNG Fix v1.0 / 2.0 Alpha 2</h4>
<p>使用简介：页面标签使用behavior:url(&rdquo;iepngfix.htc&rdquo;);来调用外部包含js、css的iepngfix.htc文件來修正PNG alpha 透明度。  官方原文：http://www.twinhelix.com/css/iepngfix/ <a href="http://www.twinhelix.com/css/iepngfix/">go</a>  测试实例：<a href="http://blog.gulu77.com/demo/200809/test_iepngfix/">http://blog.gulu77.com/demo/200809/test_iepngfix/</a></p>
<h4>4、IE7/IE8 JavaScript library</h4>
<p>使用简介：ie7/ie8-js是一个解决IE与W3C标准的冲突的JS库，使微软的IE的行为像一个Web标准兼容的浏览器，支持更多的W3C标准。  官方原文：http://code.google.com/p/ie7-js/ <a href="http://code.google.com/p/ie7-js/">go</a>  测试实例：<a href="http://blog.gulu77.com/demo/200809/test_ie7-js/">http://blog.gulu77.com/demo/200809/test_ie7-js/</a>  全部实例打包下载：<a href="http://blog.gulu77.com/demo/200809/test_png.rar">http://blog.gulu77.com/demo/200809/test_png.rar</a>  以上内容转自：<a title="gulu77" href="http://blog.gulu77.com/" target="_blank">Gulu77</a>  原文地址：<a href="http://blog.gulu77.com/?p=147" target="_blank">http://blog.gulu77.com/?p=147</a>  还发现一个方法：belatedPNG 。具体方法是将下面的代码插到&lt;head&gt;&lt;/head&gt;之间：</p>
<div class="daima">&lt;!--[if IE 6]&gt; &lt;script src=&quot;DD_belatedPNG_0.0.7a-min.js&quot;&gt;&lt;/script&gt; &lt;script&gt; DD_belatedPNG.fix('*'); &lt;/script&gt; &lt;![endif]--&gt;</div>
<p>此方法能同时解决图片和背景问题。  所用到的 js 文件您可以到作者的博客上下载，地址是：  <a href="http://www.dillerdesign.com/experiment/DD_belatedPNG/">http://www.dillerdesign.com/experiment/DD_belatedPNG/</a></p>
<p>&copy;2010 <a href="http://www.17css.com">一起CSS</a>. All Rights Reserved.</p>.<h2  class="related_post_title">相关日志</h2><ul class="related_post"><li><a href="http://www.17css.com/ie-input-hidden-bug/" title="隐藏域在ie中占空间的bug">隐藏域在ie中占空间的bug</a> (2)</li><li><a href="http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/" title="别说IE6不认识!important">别说IE6不认识!important</a> (5)</li><li><a href="http://www.17css.com/%e5%88%b6%e4%bd%9c%e5%8d%8a%e9%80%8f%e6%98%8e%e6%95%88%e6%9e%9c/" title="制作半透明效果">制作半透明效果</a> (0)</li><li><a href="http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/" title="纯css下拉菜单详解">纯css下拉菜单详解</a> (12)</li><li><a href="http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/" title="css2高级选择器">css2高级选择器</a> (4)</li><li><a href="http://www.17css.com/hover-of-the-bug-in-ie6/" title=":hover伪类在IE6中的BUG">:hover伪类在IE6中的BUG</a> (3)</li><li><a href="http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/" title="IE6双倍margin bug">IE6双倍margin bug</a> (1)</li><li><a href="http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/" title="如何在IE6里定义高度小于18px的盒子">如何在IE6里定义高度小于18px的盒子</a> (0)</li><li><a href="http://www.17css.com/ie6-max-height/" title="让IE6也有最大高度max-height的效果">让IE6也有最大高度max-height的效果</a> (7)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>别说IE6不认识!important</title>
		<link>http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/</link>
		<comments>http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 10:59:55 +0000</pubDate>
		<dc:creator>青色</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[!important]]></category>
		<category><![CDATA[IE6]]></category>

		<guid isPermaLink="false">http://www.17css.com/?p=253</guid>
		<description><![CDATA[别说IE6不认识 !important ,它们只是不够默契。 IE6 对 !important 的支持存在 bug ，有很多人因此作为 IE6 的 hack 。用多了，传多了，很多人就说 IE6 不支持 !important ，给新人带来一些影响。 在《IE6下!... ]]></description>
			<content:encoded><![CDATA[<p>别说IE6不认识 !important ,它们只是不够默契。</p>
<p>IE6 对 !important 的支持存在 bug ，有很多人因此作为 IE6 的 hack 。用多了，传多了，很多人就说 IE6 不支持 !important ，给新人带来一些影响。</p>
<p>在《<a title="IE6下!important的bug" href="http://www.17css.com/ie6%e4%b8%8bimportant%e7%9a%84bug.html">IE6下!important的bug</a>》中已经说了这个问题，现在再举几个例子说明这个问题，以下面的 XHTML 代码为例：</p>
<div class="daima">&lt;ul id="list"&gt;<br />
&lt;li class="first"&gt;这里是第一行文字&lt;/li&gt;<br />
&lt;li&gt;那这里就是第二行文字咯&lt;/li&gt;<br />
&lt;li&gt;这里应该是第三行里吧&lt;/li&gt;<br />
&lt;li&gt;这里绝对是第四行了&lt;/li&gt;<br />
&lt;/ul&gt;</div>
<p>第一个例子的 CSS 代码：</p>
<div class="daima">ul{<br />
margin:20px auto;<br />
padding:0;<br />
width:500px;<br />
list-style:none;<br />
line-height:24px;<br />
}<br />
#list li{<br />
color:blue;<br />
}<br />
.first{<br />
color:red !important;<br />
}</div>
<p><a href="http://www.17css.com/works/08/12/important1.html" target="_blank">点击这里查看效果</a></p>
<p>在 IE6 里，第一行文字为红色，!important 起作用了。如果 .first 不加 !important ，那么在所有浏览器中第一行都显示蓝色，因为 #list li 的权重比 .fisrt 高。当然 .first 改写成 #list .first 会更好，但为了举例子，所以不这样写。</p>
<p>第二个例子的 CSS 代码：</p>
<div class="daima">ul{<br />
margin:20px auto;<br />
padding:0;<br />
width:500px;<br />
list-style:none;<br />
line-height:24px;<br />
}<br />
.first{<br />
color:red !important;<br />
}<br />
.first{<br />
color:blue;<br />
}</div>
<p><a href="http://www.17css.com/works/08/12/important2.html" target="_blank">点击这里查看效果</a></p>
<p>同样，!important 在 IE6 里起效果了。</p>
<p>再看第三个例子的 CSS 代码：</p>
<div class="daima">ul{<br />
margin:20px auto;<br />
padding:0;<br />
width:500px;<br />
list-style:none;<br />
line-height:24px;<br />
}<br />
.first{<br />
color:red !important;<br />
color:blue;<br />
}</div>
<p><a href="http://www.17css.com/works/08/12/important3.html" target="_blank">点击这里查看效果</a></p>
<p>这次 !important 在 IE6 里就不起效果了。</p>
<p>综合上面三个例子得出这么一个结论：在同一个选择器内有重复的属性的话，此选择器内的此属性的 !important 在 IE6 里无效。</p>
<p>所以，并不能说 IE6 不支持 !important ，只是支持的不够好。</p>
<p>&copy;2010 <a href="http://www.17css.com">一起CSS</a>. All Rights Reserved.</p>.<h2  class="related_post_title">相关日志</h2><ul class="related_post"><li><a href="http://www.17css.com/ie-input-hidden-bug/" title="隐藏域在ie中占空间的bug">隐藏域在ie中占空间的bug</a> (2)</li><li><a href="http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/" title="IE6支持PNG透明(alpha通道)的4种方法">IE6支持PNG透明(alpha通道)的4种方法</a> (7)</li><li><a href="http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/" title="纯css下拉菜单详解">纯css下拉菜单详解</a> (12)</li><li><a href="http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/" title="css2高级选择器">css2高级选择器</a> (4)</li><li><a href="http://www.17css.com/hover-of-the-bug-in-ie6/" title=":hover伪类在IE6中的BUG">:hover伪类在IE6中的BUG</a> (3)</li><li><a href="http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/" title="IE6双倍margin bug">IE6双倍margin bug</a> (1)</li><li><a href="http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/" title="如何在IE6里定义高度小于18px的盒子">如何在IE6里定义高度小于18px的盒子</a> (0)</li><li><a href="http://www.17css.com/ie6-max-height/" title="让IE6也有最大高度max-height的效果">让IE6也有最大高度max-height的效果</a> (7)</li><li><a href="http://www.17css.com/ie6%e4%b8%8bimportant%e7%9a%84bug/" title="IE6下!important的bug">IE6下!important的bug</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>纯css下拉菜单详解</title>
		<link>http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/</link>
		<comments>http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 07:09:51 +0000</pubDate>
		<dc:creator>青色</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[下拉菜单]]></category>

		<guid isPermaLink="false">http://www.17css.com/?p=160</guid>
		<description><![CDATA[下拉菜单由于实用，所以受到人们的欢迎。下拉菜单通常是由 javascript 来实现的，也应该由 javascript 来实现，因为这属于行为层范围。然而大家知道，使用 CSS 的 :hover 伪类也可以制作下拉菜单... ]]></description>
			<content:encoded><![CDATA[<p>下拉菜单由于实用，所以受到人们的欢迎。下拉菜单通常是由 <a title="查看关于 javascript 的全部文章" href="http://www.17css.com/tag/javascript/">javascript</a> 来实现的，也应该由 <a title="查看关于 javascript 的全部文章" href="http://www.17css.com/tag/javascript/">javascript</a> 来实现，因为这属于行为层范围。然而大家知道，使用 <a href="http://www.17css.com/category/front-end/css/" title="查看关于 CSS 的全部文章">CSS</a> 的 <a href="http://www.17css.com/tag/hover/" title="查看关于 hover 的全部文章">:hover</a> 伪类也可以制作下拉菜单，比起 <a title="查看关于 javascript 的全部文章" href="http://www.17css.com/tag/javascript/">javascript</a> 来，使用 <a href="http://www.17css.com/category/front-end/css/" title="查看关于 CSS 的全部文章">CSS</a> 制作更简单，且更容易理解。但由于 <a href="http://www.17css.com/tag/ie6/" title="查看关于 IE6 的全部文章">IE6</a> 只有 a 标签支持 <a href="http://www.17css.com/tag/hover/" title="查看关于 hover 的全部文章">:hover</a> 伪类，所以又给这种带来了&ldquo;阻碍&rdquo;。不过大家还是比较喜欢纯 <a href="http://www.17css.com/category/front-end/css/" title="查看关于 CSS 的全部文章">CSS</a> 下拉菜单，现在我们就利用 <a href="http://www.17css.com/tag/ie-conditions-annotation/" title="查看关于 IE条件注释的全部文章">IE条件注释</a>来制作一个纯 <a href="http://www.17css.com/category/front-end/css/" title="查看关于 CSS 的全部文章">CSS</a> 下拉菜单。为了便于理解，选择了很很简单的代码，至于更复杂的，大家可以触类旁通、举一反三。</p>
<p>XHTML 代码：</p>
<pre class="prettyprint">
&lt;dl&gt;
	&lt;dt&gt;一级菜单&lt;/dt&gt;
	&lt;dd&gt;二级菜单&lt;/dd&gt;
	&lt;dd&gt;二级菜单&lt;/dd&gt;
	&lt;dd&gt;二级菜单&lt;/dd&gt;
&lt;/dl&gt;</pre>
<p><a href="http://www.17css.com/category/front-end/css/" title="查看关于 CSS 的全部文章">CSS</a> 代码：</p>
<pre class="prettyprint">
dd { display:none; }
dl:hover dd { display:block; }</pre>
<p><a title="CSS下拉菜单" href="http://17css.com/works/08/11/11-10a.html" target="_blank">查看Demo</a></p>
<p>在 IE7 和 <a title="查看关于 firefox 的全部文章" href="http://www.17css.com/tag/firefox/">FF</a> 等标准浏览器中，下拉菜单可以正常使用，但 <a href="http://www.17css.com/tag/ie6/" title="查看关于 IE6 的全部文章">IE6</a> 中却没有效果。  既然 <a href="http://www.17css.com/tag/ie6/" title="查看关于 IE6 的全部文章">IE6</a> 只有 a 标签才支持 <a href="http://www.17css.com/tag/hover/" title="查看关于 hover 的全部文章">:hover</a>，那就加上 a 标签。XHTML 代码改写成:</p>
<pre class="prettyprint">
&lt;!--[if lte IE 6]&gt;&lt;a href=&quot;#&quot;&gt;&lt;![endif]--&gt;
&lt;dl&gt;
	&lt;dt&gt;一级菜单&lt;/dt&gt;
	&lt;dd&gt;二级菜单&lt;/dd&gt;
	&lt;dd&gt;二级菜单&lt;/dd&gt;
	&lt;dd&gt;二级菜单&lt;/dd&gt;
&lt;/dl&gt;
&lt;!--[if lte IE 6]&gt;&lt;/a&gt;&lt;![endif]--&gt;</pre>
<p><a href="http://www.17css.com/category/front-end/css/" title="查看关于 CSS 的全部文章">CSS</a> 代码改写成：</p>
<pre class="prettyprint">
dd { display:none; }
dl:hover dd, a:hover dd { display:block; }</pre>
<p><a title="CSS下拉菜单" href="http://17css.com/works/08/11/11-10b.html">查看Demo</a></p>
<p>然而在 <a href="http://www.17css.com/tag/ie6/" title="查看关于 IE6 的全部文章">IE6</a> 中依然没有效果，为什么呢？难道代码有错？其实代码没有错，这是 <a href="http://www.17css.com/tag/ie6/" title="查看关于 IE6 的全部文章">IE6</a> 的 <a title="查看关于 bug 的全部文章" href="http://www.17css.com/tag/bug/">BUG</a>，关于次 <a title="查看关于 bug 的全部文章" href="http://www.17css.com/tag/bug/">BUG</a> 你可以参看《<a title="查看 :hover伪类在IE6中的BUG 原文" href="http://www.17css.com/hover-of-the-bug-in-ie6/">:hover伪类在IE6中的BUG</a>》。可以加上一些属性来消除此 <a title="查看关于 bug 的全部文章" href="http://www.17css.com/tag/bug/">BUG</a>，这里给 a:hover 加 border:0，即 <a href="http://www.17css.com/category/front-end/css/" title="查看关于 CSS 的全部文章">CSS</a> 代码再次改写成：</p>
<pre class="prettyprint">
dd { display:none; }
dl:hover dd, a:hover dd { display:block; }
a:hover { border:0; }</pre>
<p><a title="CSS下拉菜单" href="http://17css.com/works/08/11/11-10c.html">查看效果</a></p>
<p>此时在 <a href="http://www.17css.com/tag/ie6/" title="查看关于 IE6 的全部文章">IE6</a> 中鼠标移动到上面下拉菜单出现了。然而给每个菜单加上连接的时候，<a href="http://www.17css.com/tag/ie6/" title="查看关于 IE6 的全部文章">IE6</a> 里又不行了，为什么？为什么？不知道。。。不过再给 <a href="http://www.17css.com/tag/ie-conditions-annotation/" title="查看关于 IE条件注释的全部文章">IE条件注释</a>里的 a 标签里再套上一个表格，即 XHTML 代码改写成如下：</p>
<pre class="prettyprint">
&lt;!--[if lte IE 6]&gt;&lt;a href=&quot;#&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;![endif]--&gt;
&lt;dl&gt;
	&lt;dt&gt;&lt;a href=&quot;#&quot;&gt;一级菜单&lt;/a&gt;&lt;/dt&gt;
	&lt;dd&gt;&lt;a href=&quot;#&quot;&gt;二级菜单&lt;/a&gt;&lt;/dd&gt;
	&lt;dd&gt;&lt;a href=&quot;#&quot;&gt;二级菜单&lt;/a&gt;&lt;/dd&gt;
	&lt;dd&gt;&lt;a href=&quot;#&quot;&gt;二级菜单&lt;/a&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;!--[if lte IE 6]&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/a&gt;&lt;![endif]--&gt; </pre>
<p><a title="CSS下拉菜单" href="http://17css.com/works/08/11/11-10d.html">查看Demo</a></p>
<p>此时，下拉菜单在 <a href="http://www.17css.com/tag/ie6/" title="查看关于 IE6 的全部文章">IE6</a> 里没有问题了。</p>
<p>更多例子：</p>
<ul>
<li><a title="CSS下拉菜单" href="http://17css.com/works/08/11/11-10e.html" target="_blank">纯CSS下拉菜单1</a></li>
<li><a title="CSS下拉菜单" href="http://17css.com/works/08/11/11-10f.html" target="_blank">纯CSS下拉菜单2</a></li>
<li><a title="CSS下拉菜单" href="http://17css.com/works/08/11/11-10g.html" target="_blank">纯CSS下拉菜单3</a></li>
<li><a title="CSS下拉菜单" href="http://17css.com/works/08/11/11-10h.html" target="_blank">纯CSS下拉菜单4</a></li>
<li><a title="CSS下拉菜单" href="http://17css.com/works/08/11/11-10i.html" target="_blank">纯CSS下拉菜单5</a></li>
<li><a title="CSS下拉菜单" href="http://17css.com/works/08/11/11-10j.html" target="_blank">前沿的一个例子</a></li>
</ul>
<p>&copy;2010 <a href="http://www.17css.com">一起CSS</a>. All Rights Reserved.</p>.<h2  class="related_post_title">相关日志</h2><ul class="related_post"><li><a href="http://www.17css.com/hover-of-the-bug-in-ie6/" title=":hover伪类在IE6中的BUG">:hover伪类在IE6中的BUG</a> (3)</li><li><a href="http://www.17css.com/ie-input-hidden-bug/" title="隐藏域在ie中占空间的bug">隐藏域在ie中占空间的bug</a> (2)</li><li><a href="http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/" title="IE6支持PNG透明(alpha通道)的4种方法">IE6支持PNG透明(alpha通道)的4种方法</a> (7)</li><li><a href="http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/" title="别说IE6不认识!important">别说IE6不认识!important</a> (5)</li><li><a href="http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/" title="css2高级选择器">css2高级选择器</a> (4)</li><li><a href="http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/" title="IE6双倍margin bug">IE6双倍margin bug</a> (1)</li><li><a href="http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/" title="如何在IE6里定义高度小于18px的盒子">如何在IE6里定义高度小于18px的盒子</a> (0)</li><li><a href="http://www.17css.com/ie6-max-height/" title="让IE6也有最大高度max-height的效果">让IE6也有最大高度max-height的效果</a> (7)</li><li><a href="http://www.17css.com/%e8%a7%a3%e5%86%b3%e4%b8%8b%e6%8b%89%e8%8f%9c%e5%8d%95%e8%a2%abflash%e9%81%ae%e4%bd%8f%e9%97%ae%e9%a2%98/" title="解决下拉菜单被flash遮住问题">解决下拉菜单被flash遮住问题</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>css2高级选择器</title>
		<link>http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/</link>
		<comments>http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 12:34:20 +0000</pubDate>
		<dc:creator>青色</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[选择器]]></category>

		<guid isPermaLink="false">http://www.17css.com/?p=141</guid>
		<description><![CDATA[用 css 控制页面，必须用好选择器，否则可能会因为 css 的继承及权重等特性而得不到想要的效果。常用的 css 选择器有：标签选择器、类选择器、ID选择器。我们所见到的选择器几乎都是这三种... ]]></description>
			<content:encoded><![CDATA[<p>用 css 控制页面，必须用好选择器，否则可能会因为 css 的继承及权重等特性而得不到想要的效果。常用的 css 选择器有：标签选择器、类选择器、ID选择器。我们所见到的选择器几乎都是这三种。然而 css2 还有其他选择器，如：子选择器、相邻选择器、属性选择器，用好这些选择器，能少定义 class 或 id。那么这些 css 高级选择器怎么使用呢？</p>
<p><strong>1、</strong><strong>子选择器</strong></p>
<p>子选择器，顾名思义就是选择一个元素的子元素，不包括子元素的子元素。它的符号是大于号“&gt;”。如：</p>
<p>XHTML代码：</p>
<div class="daima">&lt;p&gt;&lt;a href="#"&gt;链接1&lt;/a&gt;&lt;span&gt;&lt;a href="#"&gt;链接2&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</div>
<p>CSS代码：</p>
<div class="daima">p&gt;a{<br />
color:#ff0000;<br />
}</div>
<p>你可以<a title="子选择器" href="http://17css.com/works/08/11/1.html" target="_blank">点击这里</a>查看效果。</p>
<p>显示效果为“链接1”是红色，而“链接2”则不受影响。如果把“&gt;”换成空格的话，那么css的继承特性会使两个 a 应用样式；如果不用子选择器的话，那就不得不给第一个 a 定义 class 或 id。</p>
<p><strong>2、</strong><strong>相邻选择器</strong></p>
<p>相邻选择器就是选择相邻的标签，它的符号是“+”。这里会出现两中情况：</p>
<p>1）如果相邻的两个标签不同，则应用到后一个标签的第一个的标签；</p>
<p>2）如果相邻的两个标签相同，则应用到该标签的除第一个以外的标签（语句有点拗口，看实例能更好的理解）。</p>
<p>以下面的XHTML为例子：</p>
<div class="daima">&lt;h2&gt;这是标题&lt;/h2&gt;<br />
&lt;p&gt;这是第一个段落&lt;/p&gt;<br />
&lt;p&gt;这是第二个段落&lt;/p&gt;<br />
&lt;p&gt;这是第三个段落&lt;/p&gt;</div>
<p>针对第一种情况：</p>
<div class="daima">h2+p{<br />
color:#ff0000;<br />
}</div>
<p><a title="相邻选择器" href="http://17css.com/works/08/11/2.html" target="_blank">查看效果</a>。效果是第一个p为红色。</p>
<p>针对第二种情况：</p>
<div class="daima">p+p{<br />
color:#ff0000;<br />
}</div>
<p><a title="相邻选择器" href="http://17css.com/works/08/11/3.html" target="_blank">查看效果</a>。效果是除第一个p外的p为红色。</p>
<p><strong>3、</strong><strong>属性选择器</strong></p>
<p>属性选择器是针对HTML标签中的属性进行选择的。例：</p>
<p>XHTML代码：</p>
<div class="daima">&lt;ul&gt;<br />
&lt;li&gt;&lt;a href="http://17css.com" title="home"&gt;网站首页&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#" title="about"&gt;关于本站&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#" title="links"&gt;友情链接&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;</div>
<p>CSS代码：</p>
<div class="daima">a[title]{<br />
text-decoration:none;<br />
}<br />
a[title="home"]{<br />
color:#ff0000;<br />
}</div>
<p><a title="属性选择器" href="http://17css.com/works/08/11/4.html" target="_blank">查看效果</a></p>
<p>a[title] 是选择定义了 title 属性的 a 标签，a[title="home"] 是选择定义了 title="home" 的a标签。另：属性可以不加双引号，也可以是单引号，如 a[title="home"] 也可以写成 a[title=home] 或 a[title='home'] 。</p>
<p>从例子中可以看到这三个选择器确实能减少网页中的class或id，但遗憾的是 IE6 均不支持。万恶的 IE6 。不过 IE6 的使用者正在减少，虽然速度比较慢，但这个趋势是不可避免的。</p>
<p>&copy;2010 <a href="http://www.17css.com">一起CSS</a>. All Rights Reserved.</p>.<h2  class="related_post_title">相关日志</h2><ul class="related_post"><li><a href="http://www.17css.com/ie-input-hidden-bug/" title="隐藏域在ie中占空间的bug">隐藏域在ie中占空间的bug</a> (2)</li><li><a href="http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/" title="IE6支持PNG透明(alpha通道)的4种方法">IE6支持PNG透明(alpha通道)的4种方法</a> (7)</li><li><a href="http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/" title="别说IE6不认识!important">别说IE6不认识!important</a> (5)</li><li><a href="http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/" title="纯css下拉菜单详解">纯css下拉菜单详解</a> (12)</li><li><a href="http://www.17css.com/hover-of-the-bug-in-ie6/" title=":hover伪类在IE6中的BUG">:hover伪类在IE6中的BUG</a> (3)</li><li><a href="http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/" title="IE6双倍margin bug">IE6双倍margin bug</a> (1)</li><li><a href="http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/" title="如何在IE6里定义高度小于18px的盒子">如何在IE6里定义高度小于18px的盒子</a> (0)</li><li><a href="http://www.17css.com/ie6-max-height/" title="让IE6也有最大高度max-height的效果">让IE6也有最大高度max-height的效果</a> (7)</li><li><a href="http://www.17css.com/css%e9%80%89%e6%8b%a9%e5%99%a8%e7%9a%84%e4%bc%98%e5%85%88%e7%ba%a7/" title="CSS选择器的优先级">CSS选择器的优先级</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>:hover伪类在IE6中的BUG</title>
		<link>http://www.17css.com/hover-of-the-bug-in-ie6/</link>
		<comments>http://www.17css.com/hover-of-the-bug-in-ie6/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 07:31:28 +0000</pubDate>
		<dc:creator>青色</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[IE6]]></category>

		<guid isPermaLink="false">http://www.17css.com/?p=153</guid>
		<description><![CDATA[:hover 是我们在 CSS 设计中最常运用的伪类之一，许多绚丽效果的实现离不开伪类 :hover，比如我们常见的纯 CSS 菜单、相册效果等等。 或许用了这么久的伪类 :hover，还有部分朋友还不完全了解 :h... ]]></description>
			<content:encoded><![CDATA[<p><a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a> 是我们在 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a> 设计中最常运用的伪类之一，许多绚丽效果的实现离不开伪类 <a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a>，比如我们常见的纯 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a> 菜单、相册效果等等。</p>
<p>或许用了这么久的伪类 <a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a>，还有部分朋友还不完全了解 <a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a> 的规则：</p>
<div class="quote">
<blockquote>在 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a>1 中此伪类仅可用于 a 对象。且对于无 href 属性（特性）的 a 对象，此伪类不发生作用。</p></blockquote>
</div>
<p>在 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a>2 中此伪类可以应用于任何对象。但目前 IE5.5、<a class="a_tags" title="查看关于 IE6 的全部文章" href="http://www.17css.com/tag/ie6/">IE6</a> 仅支持 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a>1 中的 <a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a>，不过新出的 <a class="a_tags" title="查看关于 IE7 的全部文章" href="http://www.17css.com/tag/ie7/">IE7</a> 是支持 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a>2 中的 <a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a>。</p>
<p>当我们用伪类 <a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a> 做某些特殊效果时，依据 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a>2 很好完成，但为了现在占据主流浏览器的 <a class="a_tags" title="查看关于 IE6 的全部文章" href="http://www.17css.com/tag/ie6/">IE6</a> ，我们又不得不做很多工作，比如给添加 a 元素等来模拟完成最终的效果。</p>
<p>或许这样讲太空洞，请看下面一个常见的触发显示的例子（仅选择 <a class="a_tags" title="查看关于 IE6 的全部文章" href="http://www.17css.com/tag/ie6/">IE6</a> 为例讲解）。</p>
<p>我们先用 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a>2 的写法来实现：</p>
<p>XHTML 部分：</p>
<pre class="prettyprint">
&lt;ul&gt;
	&lt;li&gt;鼠标移过来触发我吧！&lt;a href=&quot;#&quot; title=&quot;&quot;&gt;哈哈，终于被你发现了！&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<p><a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a> 部分：</p>
<pre class="prettyprint">
* { margin:0; padding:0;}
ul { list-style:none; margin:100px;}
li { height:100px; width:100px; background:#000; font-size:12px; color:#fff; position:relative;}
li a { display:none;}
li:hover a { display:block; text-decoration:none; width:100px; height:100px; background:#c00;
position:absolute; top:50px; left:50px; color:#fff;}</pre>
<p>大家可以测试发现在 <a class="a_tags" title="查看关于 Firefox 的全部文章" href="http://www.17css.com/tag/firefox/">Firefox</a> 等对 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a>2 支持很好的浏览器中，可以显示我们所要达到的效果，但在 <a class="a_tags" title="查看关于 IE6 的全部文章" href="http://www.17css.com/tag/ie6/">IE6</a> 中却无法实现。</p>
<p>下面让我们换一种思维，所用 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a>1 的写法来看看，这个时候由于无法支持 li 元素 <a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a> 的使用，我们只好把所有文字包含到 a 中，对 a 使用 <a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a> ，并且将要显示隐藏的部分放到 span 元素中，首先我们对 XHTML 进行部分调整，调整如下：</p>
<p>XHTML 部分：</p>
<pre class="prettyprint">
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;&quot;&gt;鼠标移过来触发我吧！&lt;span&gt;哈哈，终于被你发现&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<p><a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a> 中我们将 a 的设置成块级元素，并使 a 的大小和宽度和 li 的相同，并设置 a 为相对位置，用 a 来模拟上例中的 li ；而用 span 来模拟上例中的 a ，设置 span 在默认情况下隐藏（display:none;），当 a 被触发时（:hover），则 span 显示（display:block;）</p>
<p><a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a> 部分：</p>
<pre class="prettyprint">
* { margin:0; padding:0;}
ul { list-style:none; margin:100px;}
li { height:100px; width:100px; background:#000; font-size:12px;}
li a { display:block; height:100px; width:100px; position:relative; color:#fff; text-decoration:none;}
li span { display:none;}
li a:hover span { display:block; width:100px; height:100px; background:#c00;
position:absolute; top:50px; left:50px; color:#fff;}</pre>
<p>可我们发现上例中的效果，在 <a class="a_tags" title="查看关于 IE6 的全部文章" href="http://www.17css.com/tag/ie6/">IE6</a> 中依然无法显示，难道我们的代码写错了，可检查来检查去一点错误也没有（不信你找个高高手问问，他们依然会回答你，这代码完全正确），难道是标准中的说明是错的？还是 <a class="a_tags" title="查看关于 IE6 的全部文章" href="http://www.17css.com/tag/ie6/">IE6</a> 浏览器连 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a>1 也不支持？很多疑问从四面八方跑来了&hellip;&hellip;</p>
<p>那到底是什么问题呢？</p>
<p>不是标准说明的错，也不是 <a class="a_tags" title="查看关于 IE 的全部文章" href="http://www.17css.com/tag/ie/">IE</a> 浏览器不支持 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a>1，而是 IE 浏览器自身解析的问题，是 IE5.5 和 <a class="a_tags" title="查看关于 IE6 的全部文章" href="http://www.17css.com/tag/ie6/">IE6</a> 中伪类 <a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a> 的 <a class="a_tags" title="查看关于 bug 的全部文章" href="http://www.17css.com/tag/bug/">bug</a>。</p>
<p>那又该如何解决这个问题呢？</p>
<p>这个 <a class="a_tags" title="查看关于 bug 的全部文章" href="http://www.17css.com/tag/bug/">bug</a> 可以通过在链接的属性中增加某些特殊的 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a> 属性声明来消除。</p>
<p>下面我们对上面的第二个例子进行实验，究竟哪些属性可以帮我们来消除这些 <a class="a_tags" title="查看关于 bug 的全部文章" href="http://www.17css.com/tag/bug/">bug</a>。</p>
<p>对 <a class="a_tags" title="查看关于 CSS 的全部文章" href="http://www.17css.com/category/front-end/css/">CSS</a> 代码我们增加：</p>
<pre class="prettyprint">
li a:hover {}</pre>
<p>对其属性我们仅设定 width:100px; 发现在 <a class="a_tags" title="查看关于 IE6 的全部文章" href="http://www.17css.com/tag/ie6/">IE6</a> 中依旧没有变化，我们尝试着更改 width 的 value ，比如使其 width:99px，奇怪的事情发生了，在 <a class="a_tags" title="查看关于 IE6 的全部文章" href="http://www.17css.com/tag/ie6/">IE6</a> 中，隐藏的部分在触发的时候显示出来了。我们再对 li a:hover 的属性仅设定 color 来测试（初始值为 #fff），更改 color 值，发现在 <a class="a_tags" title="查看关于 IE6 的全部文章" href="http://www.17css.com/tag/ie6/">IE6</a> 下却也不能触发显示，奇怪，奇怪，真奇怪&hellip;&hellip;是不是依旧是一头雾水&hellip;&hellip;没关系，继续往下实验，或许归类了我们就能发现规律了！</p>
<p>我们再用其他属性进行设置：width，positon，background，text-decoration，font-size，font-weight，font-family，border，float，display，font-style，margin，padding，text-align，overflow，text-transform，text-indent，z-index，vertical-align。</p>
<p>我们发现除了 text-decoration，color，z-index 不能触发显示（对于不能触发显示的部分，可以还有某些遗漏的属性，欢迎朋友补充）外，其他属性均可以做为消除伪类 <a class="a_tags" title="查看关于 hover 的全部文章" href="http://www.17css.com/tag/hover/">:hover</a> <a class="a_tags" title="查看关于 bug 的全部文章" href="http://www.17css.com/tag/bug/">bug</a> 的特定属性。</p>
<p><strong>说明：</strong></p>
<ul>
<li>对于 dispaly 不可以用本例来测试，可另外写个更简单的例子（去除 ul/li，a 和 span 中的 position ）。在实际应用中怿飞不建议改变 display 值来做为特定属性消除此 <a class="a_tags" title="查看关于 bug 的全部文章" href="http://www.17css.com/tag/bug/">bug</a>，而且在某些例子中此属性不一定能消除 <a class="a_tags" title="查看关于 bug 的全部文章" href="http://www.17css.com/tag/bug/">bug</a>。</li>
<li>对于做为特定属性的 border 和 background 中的颜色我们还可用全写和简写来改变，如 #fff 和 #ffffff 在消除 <a class="a_tags" title="查看关于 bug 的全部文章" href="http://www.17css.com/tag/bug/">bug</a> 中解析为 2 个不同的值。</li>
</ul>
<p>文章转摘自：<a href="http://www.planabc.net/" title="PlanABC - 怿飞&rsquo;s Blog">PlanABC - 怿飞&rsquo;s Blog</a></p>
<p>原文地址：<a href="http://www.planabc.net/2007/02/15/ie_hover_bug/">http://www.planabc.net/2007/02/15/ie_hover_bug/</a></p>
<p>&copy;2010 <a href="http://www.17css.com">一起CSS</a>. All Rights Reserved.</p>.<h2  class="related_post_title">相关日志</h2><ul class="related_post"><li><a href="http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/" title="纯css下拉菜单详解">纯css下拉菜单详解</a> (12)</li><li><a href="http://www.17css.com/ie-input-hidden-bug/" title="隐藏域在ie中占空间的bug">隐藏域在ie中占空间的bug</a> (2)</li><li><a href="http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/" title="IE6支持PNG透明(alpha通道)的4种方法">IE6支持PNG透明(alpha通道)的4种方法</a> (7)</li><li><a href="http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/" title="别说IE6不认识!important">别说IE6不认识!important</a> (5)</li><li><a href="http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/" title="css2高级选择器">css2高级选择器</a> (4)</li><li><a href="http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/" title="IE6双倍margin bug">IE6双倍margin bug</a> (1)</li><li><a href="http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/" title="如何在IE6里定义高度小于18px的盒子">如何在IE6里定义高度小于18px的盒子</a> (0)</li><li><a href="http://www.17css.com/ie6-max-height/" title="让IE6也有最大高度max-height的效果">让IE6也有最大高度max-height的效果</a> (7)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.17css.com/hover-of-the-bug-in-ie6/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>IE6双倍margin bug</title>
		<link>http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/</link>
		<comments>http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 07:47:12 +0000</pubDate>
		<dc:creator>青色</dc:creator>
				<category><![CDATA[前端技术]]></category>
		<category><![CDATA[IE6]]></category>

		<guid isPermaLink="false">http://www.17css.com/?p=164</guid>
		<description><![CDATA[IE6双倍margin bug也就是IE6双倍外边距bug是 IE6 最著名的bug之一。它出现条件是：父元素与子元素之间，子元素同时设置了浮动和外边距属性，子元素会出现此bug，兄弟元素之间则不会。看实际例... ]]></description>
			<content:encoded><![CDATA[<p>IE6双倍margin bug也就是IE6双倍外边距bug是 IE6 最著名的bug之一。它出现条件是：父元素与子元素之间，子元素同时设置了浮动和外边距属性，子元素会出现此bug，兄弟元素之间则不会。看实际例子能更好的理解：</p>
<p>XHTML代码：</p>
<div class="daima">&lt;div id="box"&gt;<br />
&lt;div id="left"&gt;&lt;/div&gt;<br />
&lt;div id="right"&gt;&lt;/div&gt;<br />
&lt;div id="footer"&gt;&lt;/div&gt;<br />
&lt;/div&gt;</div>
<p>CSS代码：</p>
<div class="daima">*{<br />
margin:0;<br />
padding:0;<br />
}<br />
#box{<br />
width:500px;<br />
height:500px;<br />
margin-left:20px;<br />
background:#ff0000;<br />
float:left;<br />
}<br />
#left{<br />
width:200px;<br />
height:400px;<br />
background:#CCCCCC;<br />
float:left;<br />
margin-left:20px;<br />
}<br />
#right{<br />
width:200px;<br />
height:400px;<br />
background:#3366CC;<br />
float:left;<br />
margin-left:20px;<br />
}<br />
#footer{<br />
clear:both;<br />
margin-left:20px;<br />
background:#00FF00;<br />
}</div>
<p><a title="IE6双倍margin bug例子" href="http://17css.com/works/08/11/11-13a.html" target="_blank">查看效果</a>（用 IE6 查看）</p>
<p>解决的办法是给给子元素加上 display:inline 属性。如上例子给#left加上 display:inline 属性。</p>
<p><a title="解决IE6双倍margin bug例子" href="http://17css.com/works/08/11/11-13b.html" target="_blank">查看修正后的效果</a></p>
<p>&copy;2010 <a href="http://www.17css.com">一起CSS</a>. All Rights Reserved.</p>.<h2  class="related_post_title">相关日志</h2><ul class="related_post"><li><a href="http://www.17css.com/ie-input-hidden-bug/" title="隐藏域在ie中占空间的bug">隐藏域在ie中占空间的bug</a> (2)</li><li><a href="http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/" title="IE6支持PNG透明(alpha通道)的4种方法">IE6支持PNG透明(alpha通道)的4种方法</a> (7)</li><li><a href="http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/" title="别说IE6不认识!important">别说IE6不认识!important</a> (5)</li><li><a href="http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/" title="纯css下拉菜单详解">纯css下拉菜单详解</a> (12)</li><li><a href="http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/" title="css2高级选择器">css2高级选择器</a> (4)</li><li><a href="http://www.17css.com/hover-of-the-bug-in-ie6/" title=":hover伪类在IE6中的BUG">:hover伪类在IE6中的BUG</a> (3)</li><li><a href="http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/" title="如何在IE6里定义高度小于18px的盒子">如何在IE6里定义高度小于18px的盒子</a> (0)</li><li><a href="http://www.17css.com/ie6-max-height/" title="让IE6也有最大高度max-height的效果">让IE6也有最大高度max-height的效果</a> (7)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>如何在IE6里定义高度小于18px的盒子</title>
		<link>http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/</link>
		<comments>http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 08:34:47 +0000</pubDate>
		<dc:creator>青色</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[IE6]]></category>

		<guid isPermaLink="false">http://www.17css.com/?p=42</guid>
		<description><![CDATA[你遇到过定义一个较小高度（比如height:5px）的盒子在IE6里却显示不止这个高度的情况吗？ 看下面的代码: HTML代码： &#60;div id="box"&#62; &#60;div id="left"&#62;&#60;/div&#62; &#60;div id="right"&#62;&#60;/div&#62; &... ]]></description>
			<content:encoded><![CDATA[<p>你遇到过定义一个较小高度（比如height:5px）的盒子在IE6里却显示不止这个高度的情况吗？</p>
<p>看下面的代码:</p>
<p>HTML代码：</p>
<div class="daima">&lt;div id="box"&gt;<br />
&lt;div id="left"&gt;&lt;/div&gt;<br />
&lt;div id="right"&gt;&lt;/div&gt;<br />
&lt;/div&gt;</div>
<p>CSS代码：</p>
<div class="daima">*{<br />
margin:0;<br />
padding:0;<br />
}<br />
#box{<br />
width:400px;<br />
margin:5px;<br />
overflow:hidden;<br />
}<br />
#left{<br />
width:200px;<br />
float:left;<br />
background:#00f;<br />
}<br />
#right{<br />
width:200px;<br />
float:right;<br />
background:#FF0000;<br />
}</div>
<p>在4个浏览器中的效果图<a title="效果图1" href="http://17css.com/works/08/08/images/1.gif" target="_blank">点击这里</a>查看。<span id="more-42"></span></p>
<p>我们并没有给盒子定义高度，但IE6和IE7里却出现了高度，FF和opera正常。</p>
<p>给#left盒子加上height:5px后，效果图<a title="效果图2" href="http://17css.com/works/08/08/images/2.gif" target="_blank">点击这里</a>查看。</p>
<p>IE6没有变化，IE7#left盒子有了指定的高度，但#right还是有一个高度，FF和opera仍然正常。</p>
<p>再给#right盒子加上height:10px，效果图<a title="效果图3" href="http://17css.com/works/08/08/images/3.gif" target="_blank">点击这里</a>查看。</p>
<p>IE6依据没有变化。IE7正常了，FF和opera仍然正常。</p>
<p>IE7、FF和opera正常了，先把他们抛开，不理他们了，现在只看IE6，为什么IE6里的盒子明确定义了高度，它却不按指定的高度显示呢？它为什么始终显示那个高度？那个高度是多少呢？</p>
<p>我们增加#right盒子的高度，增加1px，也就是增加到11px，仍然没有变化，增加到12px、13px……直到增加到19px，终于有变化了，效果图<a title="效果图4" href="http://17css.com/works/08/08/images/4.gif" target="_blank">点击这里</a>查看。</p>
<p>由此可以断定那个高度是18px，也就是说在IE6里无法定义小于18px的高度（即使是0）；而IE7没有给盒子定义高度的话，也会有18px的高度。</p>
<p>什么原因呢？这是由于IE默认字体大小造成的。</p>
<p>解决的方法：</p>
<p>一、给盒子定义font-size:0属性；</p>
<p>二、给盒子定义overflow:hidden属性。</p>
<p>这样，在IE6、IE7、FF和opera里的效果就一样了。</p>
<p>&copy;2010 <a href="http://www.17css.com">一起CSS</a>. All Rights Reserved.</p>.<h2  class="related_post_title">相关日志</h2><ul class="related_post"><li><a href="http://www.17css.com/ie-input-hidden-bug/" title="隐藏域在ie中占空间的bug">隐藏域在ie中占空间的bug</a> (2)</li><li><a href="http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/" title="IE6支持PNG透明(alpha通道)的4种方法">IE6支持PNG透明(alpha通道)的4种方法</a> (7)</li><li><a href="http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/" title="别说IE6不认识!important">别说IE6不认识!important</a> (5)</li><li><a href="http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/" title="纯css下拉菜单详解">纯css下拉菜单详解</a> (12)</li><li><a href="http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/" title="css2高级选择器">css2高级选择器</a> (4)</li><li><a href="http://www.17css.com/hover-of-the-bug-in-ie6/" title=":hover伪类在IE6中的BUG">:hover伪类在IE6中的BUG</a> (3)</li><li><a href="http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/" title="IE6双倍margin bug">IE6双倍margin bug</a> (1)</li><li><a href="http://www.17css.com/ie6-max-height/" title="让IE6也有最大高度max-height的效果">让IE6也有最大高度max-height的效果</a> (7)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>让IE6也有最大高度max-height的效果</title>
		<link>http://www.17css.com/ie6-max-height/</link>
		<comments>http://www.17css.com/ie6-max-height/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 08:10:47 +0000</pubDate>
		<dc:creator>青色</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[max-height]]></category>

		<guid isPermaLink="false">http://www.17css.com/?p=40</guid>
		<description><![CDATA[上次写了《让IE6也有最小高度min-height的效果》，现在来写《让IE6也有最大高度man-height的效果》。 具体代码如下： height:auto !important; height:500px; max-height:500px; overflow:hidden; 解释： 1、IE6不识别max-... ]]></description>
			<content:encoded><![CDATA[<p>上次写了《让IE6也有最小高度min-height的效果》，现在来写《让IE6也有最大高度man-height的效果》。  具体代码如下：</p>
<div class="daima">height:auto !important; height:500px; max-height:500px; overflow:hidden;</div>
<p>解释：</p>
<p>1、IE6不识别max-height:500px和height:auto !important这两句，超过500px（也就是我们所希望的最大高度）后的内容将自动以藏；  </p>
<p>2、IE7及其他标准浏览器全部识别，所以有期望的效果。  </p>
<p>但仍然存在一个问题：在没有任何内容的时候，IE6里还是会有500px的高度。因为IE6对!important的解释存在bug（你可以<a href="http://www.17css.com/?p=10" title="IE6下!important的bug">点击这里</a>查看），这时IE6只认height:500px，而不认height:auto !important，所以在IE6里自然就出现500px的高度。  </p>
<p>最大高度max-height应用相对较少，因为有可能会出现某些我们没有考虑到的因素而使内容超高了这个最大高度max-height，那么就可能会使页面不美观。自己看这用不用吧！  </p>
<p>&copy;2010 <a href="http://www.17css.com">一起CSS</a>. All Rights Reserved.</p>.<h2  class="related_post_title">相关日志</h2><ul class="related_post"><li><a href="http://www.17css.com/ie-input-hidden-bug/" title="隐藏域在ie中占空间的bug">隐藏域在ie中占空间的bug</a> (2)</li><li><a href="http://www.17css.com/ie6%e6%94%af%e6%8c%81png%e9%80%8f%e6%98%8ealpha%e9%80%9a%e9%81%93%e7%9a%844%e7%a7%8d%e6%96%b9%e6%b3%95/" title="IE6支持PNG透明(alpha通道)的4种方法">IE6支持PNG透明(alpha通道)的4种方法</a> (7)</li><li><a href="http://www.17css.com/%e5%88%ab%e8%af%b4ie6%e4%b8%8d%e8%ae%a4%e8%af%86important/" title="别说IE6不认识!important">别说IE6不认识!important</a> (5)</li><li><a href="http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/" title="纯css下拉菜单详解">纯css下拉菜单详解</a> (12)</li><li><a href="http://www.17css.com/css2%e9%ab%98%e7%ba%a7%e9%80%89%e6%8b%a9%e5%99%a8/" title="css2高级选择器">css2高级选择器</a> (4)</li><li><a href="http://www.17css.com/hover-of-the-bug-in-ie6/" title=":hover伪类在IE6中的BUG">:hover伪类在IE6中的BUG</a> (3)</li><li><a href="http://www.17css.com/ie6%e5%8f%8c%e5%80%8dmargin-bug/" title="IE6双倍margin bug">IE6双倍margin bug</a> (1)</li><li><a href="http://www.17css.com/%e5%a6%82%e4%bd%95%e5%9c%a8ie6%e9%87%8c%e5%ae%9a%e4%b9%89%e9%ab%98%e5%ba%a6%e5%b0%8f%e4%ba%8e18px%e7%9a%84%e7%9b%92%e5%ad%90/" title="如何在IE6里定义高度小于18px的盒子">如何在IE6里定义高度小于18px的盒子</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.17css.com/ie6-max-height/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
