<?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>IInterest &#187; IE bug</title>
	<atom:link href="http://www.iinterest.net/tag/ie-bug/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iinterest.net</link>
	<description>关注移动互联网 &#38; HTML5</description>
	<lastBuildDate>Sat, 07 Jan 2012 08:07:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>IE下绝对定位的BUG</title>
		<link>http://www.iinterest.net/2009/07/31/ie-poistion-absolute-bug/</link>
		<comments>http://www.iinterest.net/2009/07/31/ie-poistion-absolute-bug/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 08:29:01 +0000</pubDate>
		<dc:creator>Bell</dc:creator>
				<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[IE bug]]></category>

		<guid isPermaLink="false">http://iinterest.net/blog/?p=402</guid>
		<description><![CDATA[项目中经常会用到层的绝对定位,但在IE6,IE7中它的表现却与其他浏览器存在差异,姑且算是一个IE的BUG吧(IE8除外). 先来看看这个BUG的触发条件: 先建立一个简单的模型,一个有固定宽度水平居中的容器wrapper,一个绝对定位的层position-box;这里讨论的是position-box并未设置left,right,top,bottom等属性的情况下的效果,这时候position-box对象会遵从正常的HTML布局规则,在前一个对象之后立即被呈递. &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Strict//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=gb2312&#34; /&#62; &#60;title&#62;iinterest&#60;/title&#62; &#60;style type=&#34;text/css&#34;&#62; *{ margin:0; padding:0;} .wrapper{ width:600px; height:300px; margin:0 auto; background:#FC3; overflow:hidden; } .position-box{ position:absolute; width:100px; height:100px; background:#6CF;} &#60;/style&#62; &#60;/head&#62; &#8230; <a href="http://www.iinterest.net/2009/07/31/ie-poistion-absolute-bug/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>项目中经常会用到层的绝对定位,但在IE6,IE7中它的表现却与其他浏览器存在差异,姑且算是一个IE的BUG吧(IE8除外).</p>
<p>先来看看这个BUG的触发条件:</p>
<p>先建立一个简单的模型,一个有固定宽度水平居中的容器wrapper,一个绝对定位的层position-box;<span style="color: #ff0000;">这里讨论的是position-box并未设置left,right,top,bottom等属性的情况下的效果,这时候position-box对象会遵从正常的HTML布局规则,在前一个对象之后立即被呈递.</span></p>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_OHvHi8">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;iinterest&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{ margin:0; padding:0;}
.wrapper{ width:600px; height:300px; margin:0 auto; background:#FC3; overflow:hidden; }
.position-box{ position:absolute; width:100px; height:100px; background:#6CF;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;position-box&quot;&gt;1&lt;/div&gt;
&lt;div class=&quot;wrapper&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_OHvHi8');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_OHvHi8');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>运行代码后可以看到效果:<br />
<span id="more-402"></span><br />
IE6 &amp; 7 (下文都以IE7为例)</p>
<p><img class="alignnone" title="pic" src="http://api.photoshop.com/home_aaa9cc05ee874f8fb3929d4ce5c41105/adobe-px-assets/9a1410b966d24b82be6015e189f62ff4" alt="" width="600" height="162" /></p>
<p>FF,IE8,opera&#8230; (下文都以FF为例)</p>
<p><img class="alignnone" title="pic" src="http://api.photoshop.com/home_aaa9cc05ee874f8fb3929d4ce5c41105/adobe-px-assets/6b94a7f50a8341da9c7f8688a960be6d" alt="" width="600" height="161" /></p>
<p>很明显的看出在IE6,7中position-box的定位是以wrapper容器的左顶点为起始点,而在FF中起始点是浏览器窗体的左顶点(或者说是以body顶点为起始点).</p>
<p>改变一下布局,让wrapper先于position-box载入,这时IE7中的效果就与FF中一致了(这也是与CSS文档中所描述的规则相符的,上面红字部分).</p>
<p><img class="alignnone" title="pic" src="http://api.photoshop.com/home_aaa9cc05ee874f8fb3929d4ce5c41105/adobe-px-assets/0f4cc8048d75460bb31e8adbb2200e61" alt="" width="600" height="169" /></p>
<p>然后我们把position-box放入wrapper中再增加一个向左浮动的层sidebar,让sidebar后于position-box载入,并调整sidebar的浮动方向(float:left;float:right&#8230;)看看效果:</p>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_W321l9">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;无标题文档&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{ margin:0; padding:0;}
.wrapper{ width:600px; height:300px; margin:0 auto; background:#FC3; overflow:hidden; }
.position-box{ position:absolute; width:100px; height:100px; background:#6CF;}
.sidebar{ float:left; width:200px; height:300px; background:#d7d7d7;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;wrapper&quot;&gt;
	&lt;div class=&quot;position-box&quot;&gt;1&lt;/div&gt;
    &lt;div class=&quot;sidebar&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_W321l9');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_W321l9');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><img class="alignnone" title="pic" src="http://api.photoshop.com/home_aaa9cc05ee874f8fb3929d4ce5c41105/adobe-px-assets/9cbd1dc62a7a44b583f6846c15c845ae" alt="" width="598" height="162" /></p>
<p>结果FF下,position-box并没改变,但IE7下却受到sidebar浮动方向的影响,<span style="color: #ff0000;">也就是说IE6,7的position属性会受到相邻容器布局的<strong>同时</strong>影响,</span>而非FF等浏览器中只受前一个容器布局的影响,我想这就是IE6,7中呈现出的效果与FF等浏览器中不一致的原因.</p>
<p>那么如何消除这个BUG呢,因为IE6,7会受到上下相邻容器的同时影响,所以先得把情况简单化,就是让position-box最早载入,这样就只会被后面的容器所影响(而在FF中是不会受影响的)再就是就是增加一个宽度100%的容器,这样不管后面的容易怎样布局,position-box都只会被100%宽度所影响,从而将起始点定在该容器的左顶点,最终的效果就与FF等一致了.</p>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_qHxVRx">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;无标题文档&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{ margin:0; padding:0;}
.wrapper{ width:600px; height:300px; margin:0 auto; background:#FC3; overflow:hidden; }
.position-box{ position:absolute; width:100px; height:100px; background:#6CF;}
.sidebar{ float:left; width:200px; height:300px; background:#d7d7d7;}
.clear{ width:100%; height:0px; overflow:hidden;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;wrapper&quot;&gt;
	&lt;div class=&quot;position-box&quot;&gt;1&lt;/div&gt;
    &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
    &lt;div class=&quot;sidebar&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_qHxVRx');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_qHxVRx');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><img class="alignnone" title="pic"  src="http://api.photoshop.com/home_aaa9cc05ee874f8fb3929d4ce5c41105/adobe-px-assets/44bebcbdfa5b4ea4b61729a0380937e9" width="400" height="200"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iinterest.net/2009/07/31/ie-poistion-absolute-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用jQuery解决IE下&lt;select &gt;被截断的BUG</title>
		<link>http://www.iinterest.net/2009/01/15/select-cutt-off-bugs-on-ie/</link>
		<comments>http://www.iinterest.net/2009/01/15/select-cutt-off-bugs-on-ie/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 07:07:48 +0000</pubDate>
		<dc:creator>Bell</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[IE bug]]></category>

		<guid isPermaLink="false">http://iinterest.net/blog/?p=175</guid>
		<description><![CDATA[        &#60;select&#62;是我们常用的控件,但在IE下却存在一个令人困扰的BUG,就是在定义了&#60;select&#62;宽度的情况下,&#60;option&#62;里的内容宽度超过&#60;select&#62;定义宽度的话,超出的部分将被截断&#8230;影响用户的正常浏览.(而在FF,webkis内核的浏览器里会被正确的解析,如图) 如何解决: 这里用到了jQuery(最近在学这个,^_^),看看代码: &#60;!&#8211;[if IE]&#62; &#60;script type=”text/javascript”&#62; $(document).ready(function() { $(“#demo”)  .focus(function(){   $(this).data(“selectWidth”, $(this).css(“width”)).css(“width”, “auto”);   $(this).css({ position:”absolute” });  })  .blur(function(){   $(this).css(“width”, $(this).data(“selectWidth”));  }); }); &#60;/script&#62; &#60;![endif]&#8211;&#62; 思路是当&#60;select&#62;获得焦点时,将&#60;select&#62;的宽度设为auto,失去焦点时还原.   2个值得注意的地方: 1.因为是IE的BUG,所以用了&#60;!&#8211;[if IE]&#62; 2.为了不破坏布局所以加了这一句:$(this).css({ position:”absolute” }); 看看实际的效果: Demo 目前这还只是一个雏形,还需要优化,如果大家有什么好的建议欢迎留言]]></description>
			<content:encoded><![CDATA[<p>        &lt;select&gt;是我们常用的控件,但在IE下却存在一个令人困扰的BUG,就是在定义了&lt;select&gt;宽度的情况下,&lt;option&gt;里的内容宽度超过&lt;select&gt;定义宽度的话,超出的部分将被截断&#8230;影响用户的正常浏览.(而在FF,webkis内核的浏览器里会被正确的解析,如图)</p>
<p><img class="alignnone size-full wp-image-176" title="select" src="http://iinterest.net/blog/wp-content/uploads/2009/01/select.jpg" alt="select" width="500" height="166" /></p>
<p><span id="more-175"></span></p>
<p><span style="color: #ff0000;">如何解决:<br />
</span>这里用到了jQuery(最近在学这个,^_^),看看代码:</p>
<blockquote><p>&lt;!&#8211;[if IE]&gt;<br />
&lt;script type=”text/javascript”&gt;<br />
$(document).ready(function() {<br />
$(“#demo”)<br />
 .focus(function(){<br />
  $(this).data(“selectWidth”, $(this).css(“width”)).css(“width”, “auto”);<br />
  $(this).css({ position:”absolute” });<br />
 })<br />
 .blur(function(){<br />
  $(this).css(“width”, $(this).data(“selectWidth”));<br />
 });<br />
});<br />
&lt;/script&gt;<br />
&lt;![endif]&#8211;&gt;</p></blockquote>
<p>思路是当&lt;select&gt;获得焦点时,将&lt;select&gt;的宽度设为auto,失去焦点时还原.</p>
<p> <img class="alignnone size-full wp-image-179" title="select2" src="http://iinterest.net/blog/wp-content/uploads/2009/01/select2.jpg" alt="select2" width="487" height="31" /></p>
<p><span style="color: #ff0000;">2个值得注意的地方:<br />
</span>1.因为是IE的BUG,所以用了<span style="color: #008080;">&lt;!&#8211;[if IE]&gt;</span><br />
2.为了不破坏布局所以加了这一句:<span style="color: #008080;">$(this).css({ position:”absolute” });</span></p>
<p>看看实际的效果: <a href="http://iinterest.net/blog/demo/select.html" target="_blank"><strong>Demo</strong></a></p>
<p>目前这还只是一个雏形,还需要优化,如果大家有什么好的建议欢迎留言 <img src='http://www.iinterest.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.iinterest.net/2009/01/15/select-cutt-off-bugs-on-ie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

