<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[刘新修]]></title> 
<link>http://liuxinxiu.com:80/index.php</link> 
<description><![CDATA[刘新修的个人博客 (Liuxinxiu'S Blog)]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[刘新修]]></copyright>
<item>
<link>http://liuxinxiu.com:80/fixed_ie6_dont_support_bug/</link>
<title><![CDATA[修正IE6不支持position:fixed的bug]]></title> 
<author>刘新修 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[H5/JS/CSS]]></category>
<pubDate>Thu, 30 Aug 2012 13:33:46 +0000</pubDate> 
<guid>http://liuxinxiu.com:80/fixed_ie6_dont_support_bug/</guid> 
<description>
<![CDATA[ 
	<p>众所周知IE6不支持position:fixed，这个bug与IE6的双倍margin和不支持PNG透明等bug一样臭名昭著。前些天我做自己的博客模板的时候，遇到了这个问题。当时就简单的无视了IE6&mdash;&mdash;尽管有几个使用IE6的朋友，一起BS我&hellip;&hellip;但是对于大项目或商业网站，如果有用到这个属性的时候，是不可能直接无视的。</p><h3>如何解决&ldquo;振动&rdquo;的问题？</h3><p>显然IE有一个多步的渲染进程。当你滚动或调整你的浏览器大小的时候，它将重置所有内容并重画页面，这个时候它就会重新处理css表达式。这会引起一个丑陋的&ldquo;振动&rdquo;bug，在此处固定位置的元素需要调整以跟上你的(页面的)滚动，于是就会&ldquo;跳动&rdquo;。</p><p>解决此问题的技巧就是使用<code>background-attachment:fixed</code>为body或html元素添加一个background-image。这就会强制页面在重画之前先处理CSS。因为是在重画之前处理CSS，它也就会同样在重画之前首先处理你的CSS表达式。这将让你实现完美的平滑的固定位置元素！</p><p>我发现的另外一个小技巧是，你根本无需一个真实的图片！你可以使用一个<code>about:blank</code>替代一个spacer.gif图片，而且它工作的同样出色。</p><p><span style="color: #0000ff">/*让position:fixed在IE6下可用! */ <br />.fixed-top /* 头部固定 */&#123;position:fixed;bottom:auto;top:0px;&#125;<br />.fixed-bottom /* 底部固定 */&#123;position:fixed;bottom:0px;top:auto;&#125;<br />.fixed-left /* 左侧固定 */&#123;position:fixed;right:auto;left:0px;&#125;<br />.fixed-right /* 右侧固定 */&#123;position:fixed;right:0px;left:auto;&#125;<br />/* 上面的是除了IE6的主流浏览器通用的方法 */<br />* html,* html body /* 修正IE6振动bug */&#123;background-image:url(about:blank);background-attachment:fixed;&#125;<br />* html .fixed-top /* IE6 头部固定 */&#123;position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop));&#125;<br />* html .fixed-right /* IE6 右侧固定 */ &#123;position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)&#124;&#124;0)-(parseInt(this.currentStyle.marginRight,10)&#124;&#124;0));&#125;<br />* html .fixed-bottom /* IE6 底部固定&nbsp; */&#123;position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)&#124;&#124;0)-(parseInt(this.currentStyle.marginBottom,10)&#124;&#124;0)));&#125;<br />* html .fixed-left /* IE6 左侧固定 */&#123;position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft));&#125;<br /></span></p>
]]>
</description>
</item><item>
<link>http://liuxinxiu.com:80/fixed_ie6_dont_support_bug/#blogcomment</link>
<title><![CDATA[[评论] 修正IE6不支持position:fixed的bug]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://liuxinxiu.com:80/fixed_ie6_dont_support_bug/#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>