<?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>CSSASS &#187; margin</title>
	<atom:link href="http://www.cssass.com/blog/index.php/tag/margin/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cssass.com/blog</link>
	<description>三人行必有我师焉，择其善者而从之，其不善者而改之</description>
	<lastBuildDate>Wed, 08 Sep 2010 05:41:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>斯芬克斯之谜续——IE下失效的margin-left/right</title>
		<link>http://www.cssass.com/blog/index.php/2009/350.html</link>
		<comments>http://www.cssass.com/blog/index.php/2009/350.html#comments</comments>
		<pubDate>Tue, 26 May 2009 06:20:44 +0000</pubDate>
		<dc:creator>ONEBOYS</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[border]]></category>
		<category><![CDATA[haslayout]]></category>
		<category><![CDATA[margin]]></category>

		<guid isPermaLink="false">http://www.cssass.com/blog/?p=350</guid>
		<description><![CDATA[margin-left/right也会失效？
一般很多人遇到的margin失效都是纵向上面的:
一种情况是元素的确不支持margin-top/bottom(参看：关于margin-top/bottom在inline元素（non-Replaced）上不起作用的解释);
另一种情况则是元素产生了margin叠加（参看：如何避开麻烦的margin叠加(margin collapsing)）。
那么margin-left/right怎么又会失效的呢？假如看过斯芬克斯之谜-IE私有属性haslayout的困扰那篇文章的童鞋，就会了解了：哦，又是haslayout啊。
我们来看看具体的失效代码：


&#60;!DOCTYPE html&#62;
&#60;html&#62;
&#60;head&#62;
&#60;meta content=&#34;text/html;charset=utf-8&#34; http-equiv=&#34;Content-Type&#34; /&#62;
&#60;title&#62;斯芬克斯之谜续——无效的margin-left/right(ie)&#60;/title&#62;
&#60;style&#62;
.wrap{background:#eee;border:1px solid #ccc;}
.cont{border-bottom:2px solid #aaa;margin:0 30px;height:30px;}
&#60;/style&#62;
&#60;/head&#62;
&#60;body&#62;
&#60;div class=&#34;wrap&#34;&#62;
        &#60;div class=&#34;cont&#34;&#62;热门圈子&#60;/div&#62;
&#60;/div&#62;
&#60;/body&#62;
&#60;/html&#62;

  

我们会发现：.cont的margin:0 30px再IE下失效了。。。
好，既然说haslayout的问题，那么，我们知道,height属性会触发haslayout。去除.cont的height试试，果然margin-left/right起效了。
不过，不要急，我们可以消除触发子级元素的haslayout来解决失效，也可以给父级元素触发haslyout来解决这个问题：在.wrap上增加属性:zoom:1;
那么，所有谜团都在这里了吗？
我们试试，不改动其他属性，去除父级.wrap上的border。我们发现，margin-left/right也不会失效了&#8230;
(看来，border这个属性，还得多加研究啊。之前也遇到过类似border引起的问题的。。。)
haslayout的一点资料可以看这里：On having layout抄录


Related posts:footer居于页面底部。当页面不够长时，居窗口底部  当网页内容不够长时，footer将居于窗口的底部。而不是紧跟上部分网页内容。 当页面足够长，footer将被挤下，而不是仍然固定在窗口底部。 （始终固定在窗口底部的fixed效果看这篇文章：footer始终固定于窗口底部(支持ie6的fixed效果)）。 &#60;!DOCTYPE html&#62; &#60;html&#62; &#60;head&#62; &#60;meta charset=&#34;utf-8&#34;...简单效果的简单写法——无缝滚动字幕  &#60;style&#62; *{padding:0;margin:0;font-size:12px;} #wrap{width:300px;background:#eee;} #wrap li{height:22px;line-height:22px;} &#60;/style&#62; &#60;div id=&#34;wrap&#34; style=&#34;overflow:hidden;height:100px;&#34;&#62;...三列互适应等高且中列宽度自适应布局的几个方法（圣杯布局） 前面写过一篇二列右列宽度自适应布局的四种方法 。 先扩展出来“三列，左右列宽度固定，中间列宽度适应屏幕”。 采用二列布局的四种方法中的最后一种：触发haslayout法。(当然其他方法也可以用,比如把中间列中触发haslayout的zoom:1和为firefox而加overflow:hidden;替换为margin:0 auto;) &#60;!DOCTYPE html&#62; &#60;html&#62; [...]


Related posts:<ol><li><a href='http://www.cssass.com/blog/index.php/2008/15.html' rel='bookmark' title='Permanent Link: footer居于页面底部。当页面不够长时，居窗口底部'>footer居于页面底部。当页面不够长时，居窗口底部</a> <small> 当网页内容不够长时，footer将居于窗口的底部。而不是紧跟上部分网页内容。 当页面足够长，footer将被挤下，而不是仍然固定在窗口底部。 （始终固定在窗口底部的fixed效果看这篇文章：footer始终固定于窗口底部(支持ie6的fixed效果)）。 &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;...</small></li><li><a href='http://www.cssass.com/blog/index.php/2009/547.html' rel='bookmark' title='Permanent Link: 简单效果的简单写法——无缝滚动字幕'>简单效果的简单写法——无缝滚动字幕</a> <small> &lt;style&gt; *{padding:0;margin:0;font-size:12px;} #wrap{width:300px;background:#eee;} #wrap li{height:22px;line-height:22px;} &lt;/style&gt; &lt;div id=&quot;wrap&quot; style=&quot;overflow:hidden;height:100px;&quot;&gt;...</small></li><li><a href='http://www.cssass.com/blog/index.php/2008/42.html' rel='bookmark' title='Permanent Link: 三列互适应等高且中列宽度自适应布局的几个方法（圣杯布局）'>三列互适应等高且中列宽度自适应布局的几个方法（圣杯布局）</a> <small>前面写过一篇二列右列宽度自适应布局的四种方法 。 先扩展出来“三列，左右列宽度固定，中间列宽度适应屏幕”。 采用二列布局的四种方法中的最后一种：触发haslayout法。(当然其他方法也可以用,比如把中间列中触发haslayout的zoom:1和为firefox而加overflow:hidden;替换为margin:0 auto;) &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;左右列固定宽度，中间列宽度自适应&lt;/title&gt;...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>margin-left/right也会失效？<br />
一般很多人遇到的margin失效都是纵向上面的:<br />
一种情况是元素的确不支持margin-top/bottom(参看：<a href="/blog/?p=121" target="_blank">关于margin-top/bottom在inline元素（non-Replaced）上不起作用的解释</a>);<br />
另一种情况则是元素产生了margin叠加（参看：<a href="/blog/?p=164" target="_blank">如何避开麻烦的margin叠加(margin collapsing)</a>）。</p>
<p>那么margin-left/right怎么又会失效的呢？假如看过<a href="/blog/?p=147" target="_blank">斯芬克斯之谜-IE私有属性haslayout的困扰</a>那篇文章的童鞋，就会了解了：哦，又是haslayout啊。</p>
<p>我们来看看具体的失效代码：</p>
<div class="runcode">
<p><span class='areaBox' onmousedown="runcode.resize(this,event);"><textarea name="runcode" class="runcode_text" id="runcode_oMrEHX" onmousedown="(document.all)?(event.cancelBubble = true) : (event.stopPropagation())">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta content=&quot;text/html;charset=utf-8&quot; http-equiv=&quot;Content-Type&quot; /&gt;
&lt;title&gt;斯芬克斯之谜续——无效的margin-left/right(ie)&lt;/title&gt;
&lt;style&gt;
.wrap{background:#eee;border:1px solid #ccc;}
.cont{border-bottom:2px solid #aaa;margin:0 30px;height:30px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;wrap&quot;&gt;
        &lt;div class=&quot;cont&quot;&gt;热门圈子&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></span></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode.open_new('runcode_oMrEHX');"/> <input type="button" value="选择" class="runcode_button" onclick="runcode.copy('runcode_oMrEHX');"/> </p>
</div>
<p>我们会发现：.cont的margin:0 30px再IE下失效了。。。<br />
好，既然说haslayout的问题，那么，我们知道,height属性会触发haslayout。去除.cont的height试试，果然margin-left/right起效了。<br />
不过，不要急，我们可以消除触发子级元素的haslayout来解决失效，也可以给父级元素触发haslyout来解决这个问题：在.wrap上增加属性:zoom:1;<br />
那么，所有谜团都在这里了吗？<br />
我们试试，不改动其他属性，去除父级.wrap上的border。我们发现，margin-left/right也不会失效了&#8230;<br />
(看来，border这个属性，还得多加研究啊。之前也遇到过类似border引起的问题的。。。)<br />
haslayout的一点资料可以看这里：<a href="/blog/?p=35" target="_blank">On having layout抄录</a></p>


<p>Related posts:<ol><li><a href='http://www.cssass.com/blog/index.php/2008/15.html' rel='bookmark' title='Permanent Link: footer居于页面底部。当页面不够长时，居窗口底部'>footer居于页面底部。当页面不够长时，居窗口底部</a> <small> 当网页内容不够长时，footer将居于窗口的底部。而不是紧跟上部分网页内容。 当页面足够长，footer将被挤下，而不是仍然固定在窗口底部。 （始终固定在窗口底部的fixed效果看这篇文章：footer始终固定于窗口底部(支持ie6的fixed效果)）。 &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;...</small></li><li><a href='http://www.cssass.com/blog/index.php/2009/547.html' rel='bookmark' title='Permanent Link: 简单效果的简单写法——无缝滚动字幕'>简单效果的简单写法——无缝滚动字幕</a> <small> &lt;style&gt; *{padding:0;margin:0;font-size:12px;} #wrap{width:300px;background:#eee;} #wrap li{height:22px;line-height:22px;} &lt;/style&gt; &lt;div id=&quot;wrap&quot; style=&quot;overflow:hidden;height:100px;&quot;&gt;...</small></li><li><a href='http://www.cssass.com/blog/index.php/2008/42.html' rel='bookmark' title='Permanent Link: 三列互适应等高且中列宽度自适应布局的几个方法（圣杯布局）'>三列互适应等高且中列宽度自适应布局的几个方法（圣杯布局）</a> <small>前面写过一篇二列右列宽度自适应布局的四种方法 。 先扩展出来“三列，左右列宽度固定，中间列宽度适应屏幕”。 采用二列布局的四种方法中的最后一种：触发haslayout法。(当然其他方法也可以用,比如把中间列中触发haslayout的zoom:1和为firefox而加overflow:hidden;替换为margin:0 auto;) &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;左右列固定宽度，中间列宽度自适应&lt;/title&gt;...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.cssass.com/blog/index.php/2009/350.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>关于margin-top/bottom在non-Replaced inline元素上不起作用的解释</title>
		<link>http://www.cssass.com/blog/index.php/2009/121.html</link>
		<comments>http://www.cssass.com/blog/index.php/2009/121.html#comments</comments>
		<pubDate>Fri, 27 Feb 2009 07:07:51 +0000</pubDate>
		<dc:creator>ONEBOYS</dc:creator>
				<category><![CDATA[一己之见]]></category>
		<category><![CDATA[inline]]></category>
		<category><![CDATA[margin]]></category>
		<category><![CDATA[Replaced]]></category>

		<guid isPermaLink="false">http://oneboys.host004.dns2004.cn/?p=121</guid>
		<description><![CDATA[margin-top/bottom have no effect on non-replaced inline elements。（参见css2.1规范）
但是为什么就不支持呢？
本人觉得可以这样解释：
像这样一个结构
&#60;span class=&#8221;a&#8221;&#62;xxxxxxxxxxxxxxxx&#60;/span&#62;&#60;span class=&#8221;b&#8221;&#62;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#60;/span&#62;
效果大概如下
xxxxxxxxxxxxxxx&#8212;&#8212;&#8212;&#8212;-
假如inline元素支持margin-top，而margin-top的参照基准是前一个元素（当然，考虑复杂情况的话，这么说是不正确的,比如前一元素是脱离文档流的元素，或者根本没有前一元素而只有上级元素，等等）。那么给b相对a的设置一个margin-top值，这个效果会是怎么呢？
这样？
xxxxxxxxxxxxxxx
&#8212;&#8212;&#8212;&#8212;-
还是这样？
xxxxxxxxxxxxxxx
                                     &#8212;&#8212;&#8212;&#8212;-
但不管是怎样，这都和inline元素的定义相悖。inline元素，从字面上就可以理解，他是在(in)一行(line)上的！
这就是为什么inline元素当初设计的时候不让它支持margin-top/bottom。
同样他（非可置换inline元素）也不支持height（和width）。取而代之的是line-height，意思就是行高。因为inline元素是一行行的，定一个height的话，那这到底是整段inline元素的高呢？还是inline元素一行的高呢？都说不过去啊！所以统一都给每行定一个高，这就是line-height了。
虽然no-replaced inline元素都不支持margin属性。
但margin对于可置换inline元素还是有效的.(Replaced element )
例如下，下面的margin-top/bottom就生效了吧.


&#60;!DOCTYPE html&#62;
&#60;html&#62;
&#60;head&#62;
&#60;meta charset=&#34;utf-8&#34; /&#62;
&#60;title&#62;可置换inline元素的margin效果&#60;/title&#62;
&#60;style type=&#34;text/css&#34;&#62;
*{margin:0; padding:0; }
.inputButton{margin-top:100px;}
&#60;/style&#62;
&#60;/head&#62;
&#60;body&#62;
&#60;div style=&#34;border:1px solid red;&#34;&#62;
	&#60;input type=&#34;text&#34; class=&#34;inputText&#34; /&#62;&#60;input type=&#34;button&#34; value=&#34;提交&#34; class=&#34;inputButton&#34; /&#62;
&#60;/div&#62;
&#60;/body&#62;
&#60;/html&#62;

  

不过，等下，为什么在这里对inputButton设置margin-top后inputText也跟着有了上边距了呢？
其实，对于可置换inline元素的margin作用基线和block元素又不一样，他并非是任意的前面那个元素，而是离他最近的前一个block元素。
而且，对于元素有一个默认的vertical-align值。
ie下有可能是：vertical-align:auto; （但标准css规范中并无auto这个值）
而FF等浏览器下是vertical-align:baseline;（规范中所定义）
我们给input这个可置换inline元素设置个vertical-align:top;看看，前面的inputText是不是就看不出有“上边距”了。


&#60;!DOCTYPE html&#62;
&#60;html&#62;
&#60;head&#62;
&#60;meta charset=&#34;utf-8&#34; /&#62;
&#60;title&#62;可置换inline元素的margin效果&#60;/title&#62;
&#60;style type=&#34;text/css&#34;&#62;
*{margin:0; padding:0; }
input{vertical-align:top;}
.inputButton{margin-top:100px;}
&#60;/style&#62;
&#60;/head&#62;
&#60;body&#62;
&#60;div style=&#34;border:1px solid red;&#34;&#62;
	&#60;input type=&#34;text&#34; [...]


Related posts:<ol><li><a href='http://www.cssass.com/blog/index.php/2010/490.html' rel='bookmark' title='Permanent Link: 小结line-height和vertical-align'>小结line-height和vertical-align</a> <small>line-height可以应用在所有元素上。 但尽管line-height可以加在block元素上，实际起作用的却是内部的inline元素或textnode节点(也体现了它的继承性质)。 &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot; /&gt; &lt;title&gt;line-height对非可置换inline元素的影响&lt;/title&gt;...</small></li><li><a href='http://www.cssass.com/blog/index.php/2009/69.html' rel='bookmark' title='Permanent Link: input(button)的空隙'>input(button)的空隙</a> <small>按钮中的文字和边缘都是有一段默认距离的： &lt;input type=&quot;submit&quot; value=&quot;提交提交提交&quot; /&gt;&lt;br /&gt; &lt;button type=&quot;submit&quot; value=&quot;提交提交提交&quot; &gt;提交提交提交&lt;/button&gt;...</small></li><li><a href='http://www.cssass.com/blog/index.php/2008/5.html' rel='bookmark' title='Permanent Link: 未知大小图片在已知容器中居中'>未知大小图片在已知容器中居中</a> <small>以下是一些从网上收集来的各种适用于&#8221;未知尺寸图层的垂直居中&#8221;方法 &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; .box { border:1px solid...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>margin-top/bottom have no effect on non-replaced inline elements。（参见css2.1规范）<br />
但是为什么就不支持呢？<br />
本人觉得可以这样解释：</p>
<p>像这样一个结构<br />
&lt;span class=&#8221;a&#8221;&gt;xxxxxxxxxxxxxxxx&lt;/span&gt;&lt;span class=&#8221;b&#8221;&gt;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&lt;/span&gt;</p>
<p>效果大概如下<br />
xxxxxxxxxxxxxxx&#8212;&#8212;&#8212;&#8212;-</p>
<p>假如inline元素支持margin-top，而margin-top的参照基准是前一个元素（当然，考虑复杂情况的话，这么说是不正确的,比如前一元素是脱离文档流的元素，或者根本没有前一元素而只有上级元素，等等）。那么给b相对a的设置一个margin-top值，这个效果会是怎么呢？</p>
<p>这样？<br />
xxxxxxxxxxxxxxx<br />
&#8212;&#8212;&#8212;&#8212;-</p>
<p>还是这样？<br />
xxxxxxxxxxxxxxx<br />
                                     &#8212;&#8212;&#8212;&#8212;-</p>
<p>但不管是怎样，这都和inline元素的定义相悖。inline元素，从字面上就可以理解，他是在(in)一行(line)上的！<br />
这就是为什么inline元素当初设计的时候不让它支持margin-top/bottom。</p>
<p>同样他（非可置换inline元素）也不支持height（和width）。取而代之的是line-height，意思就是行高。因为inline元素是一行行的，定一个height的话，那这到底是整段inline元素的高呢？还是inline元素一行的高呢？都说不过去啊！所以统一都给每行定一个高，这就是line-height了。</p>
<p>虽然no-replaced inline元素都不支持margin属性。<br />
但margin对于可置换inline元素还是有效的.(<a href="http://www.w3.org/TR/CSS21/conform.html" target="_blank" >Replaced element</a> )</p>
<p>例如下，下面的margin-top/bottom就生效了吧.</p>
<div class="runcode">
<p><span class='areaBox' onmousedown="runcode.resize(this,event);"><textarea name="runcode" class="runcode_text" id="runcode_nJ_IN9" onmousedown="(document.all)?(event.cancelBubble = true) : (event.stopPropagation())">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;title&gt;可置换inline元素的margin效果&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{margin:0; padding:0; }
.inputButton{margin-top:100px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div style=&quot;border:1px solid red;&quot;&gt;
	&lt;input type=&quot;text&quot; class=&quot;inputText&quot; /&gt;&lt;input type=&quot;button&quot; value=&quot;提交&quot; class=&quot;inputButton&quot; /&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></span></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode.open_new('runcode_nJ_IN9');"/> <input type="button" value="选择" class="runcode_button" onclick="runcode.copy('runcode_nJ_IN9');"/> </p>
</div>
<p>不过，等下，为什么在这里对inputButton设置margin-top后inputText也跟着有了上边距了呢？<br />
其实，对于可置换inline元素的margin作用基线和block元素又不一样，他并非是任意的前面那个元素，而是离他最近的前一个block元素。<br />
而且，对于元素有一个默认的vertical-align值。<br />
ie下有可能是：vertical-align:auto; （但标准css规范中并无auto这个值）<br />
而FF等浏览器下是vertical-align:baseline;（规范中所定义）</p>
<p>我们给input这个可置换inline元素设置个vertical-align:top;看看，前面的inputText是不是就看不出有“上边距”了。</p>
<div class="runcode">
<p><span class='areaBox' onmousedown="runcode.resize(this,event);"><textarea name="runcode" class="runcode_text" id="runcode_03cuw4" onmousedown="(document.all)?(event.cancelBubble = true) : (event.stopPropagation())">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;title&gt;可置换inline元素的margin效果&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{margin:0; padding:0; }
input{vertical-align:top;}
.inputButton{margin-top:100px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div style=&quot;border:1px solid red;&quot;&gt;
	&lt;input type=&quot;text&quot; class=&quot;inputText&quot; /&gt;&lt;input type=&quot;button&quot; value=&quot;提交&quot; class=&quot;inputButton&quot; /&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></span></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode.open_new('runcode_03cuw4');"/> <input type="button" value="选择" class="runcode_button" onclick="runcode.copy('runcode_03cuw4');"/> </p>
</div>
<p>有时候，margin的值在不同浏览器下会产生不同的结果。<br />
比如这个：</p>
<div class="runcode">
<p><span class='areaBox' onmousedown="runcode.resize(this,event);"><textarea name="runcode" class="runcode_text" id="runcode_Az_EAZ" onmousedown="(document.all)?(event.cancelBubble = true) : (event.stopPropagation())">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf8&quot; /&gt;
&lt;title&gt;可置换inline元素的margin效果&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{margin:0; padding:0; }
.inputButton{margin-top:-100px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;border:1px solid red;&quot;&gt;
	&lt;input type=&quot;text&quot; class=&quot;inputText&quot; /&gt;&lt;input type=&quot;button&quot; value=&quot;提交&quot; class=&quot;inputButton&quot; /&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></span></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode.open_new('runcode_Az_EAZ');"/> <input type="button" value="选择" class="runcode_button" onclick="runcode.copy('runcode_Az_EAZ');"/> </p>
</div>
<p>对比下ie和FF的差别，我们会发现在，ＦＦ下这个margin负值似乎没起作用啊。<br />
其实是vertical-align值（有默认值）在不同浏览器下解释有差别的缘故。<br />
你可以修改input的vertical-align值做下测试。</p>


<p>Related posts:<ol><li><a href='http://www.cssass.com/blog/index.php/2010/490.html' rel='bookmark' title='Permanent Link: 小结line-height和vertical-align'>小结line-height和vertical-align</a> <small>line-height可以应用在所有元素上。 但尽管line-height可以加在block元素上，实际起作用的却是内部的inline元素或textnode节点(也体现了它的继承性质)。 &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot; /&gt; &lt;title&gt;line-height对非可置换inline元素的影响&lt;/title&gt;...</small></li><li><a href='http://www.cssass.com/blog/index.php/2009/69.html' rel='bookmark' title='Permanent Link: input(button)的空隙'>input(button)的空隙</a> <small>按钮中的文字和边缘都是有一段默认距离的： &lt;input type=&quot;submit&quot; value=&quot;提交提交提交&quot; /&gt;&lt;br /&gt; &lt;button type=&quot;submit&quot; value=&quot;提交提交提交&quot; &gt;提交提交提交&lt;/button&gt;...</small></li><li><a href='http://www.cssass.com/blog/index.php/2008/5.html' rel='bookmark' title='Permanent Link: 未知大小图片在已知容器中居中'>未知大小图片在已知容器中居中</a> <small>以下是一些从网上收集来的各种适用于&#8221;未知尺寸图层的垂直居中&#8221;方法 &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; .box { border:1px solid...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.cssass.com/blog/index.php/2009/121.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
