<?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>Silentash-默尘 &#187; dashed</title>
	<atom:link href="http://blog.silentash.com/tag/dashed/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.silentash.com</link>
	<description>尘埃默默，风雨洗礼</description>
	<lastBuildDate>Tue, 24 Aug 2010 16:31:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dotted&amp;Dashed终极分析及IE6透明边框</title>
		<link>http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw</link>
		<comments>http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw#comments</comments>
		<pubDate>Mon, 28 Dec 2009 17:09:47 +0000</pubDate>
		<dc:creator>nunumick</dc:creator>
				<category><![CDATA[WEB标准]]></category>
		<category><![CDATA[XHTML/CSS]]></category>
		<category><![CDATA[border]]></category>
		<category><![CDATA[dashed]]></category>
		<category><![CDATA[dotted]]></category>
		<category><![CDATA[transparent]]></category>

		<guid isPermaLink="false">http://www.silentash.com/blog/?p=241</guid>
		<description><![CDATA[dotted和dashed是几个Border-style类型里面最常用又是最容易被混淆的，从字面上我们可以知道dotted代表点线，dashed代表虚线，不过是怎样的点线和虚线，我们无从得知。W3C也仅仅是从字面上对这两者进行了定义和解释，如同讲废话一样将解释权踢给了各浏览器开发商。浏览器混乱的给出自己的解释，其中“造就”的罪过，最终降临在WEB开发者身上...]]></description>
			<content:encoded><![CDATA[<p>dotted和dashed是几个Border-style类型里面最常用又是最容易被混淆的，从字面上我们可以知道dotted代表点线，dashed代表虚线，不过是怎样的点线和虚线，我们无从得知。W3C也仅仅是从字面上对这两者进行了定义和解释，如同讲废话一样将解释权踢给了各浏览器开发商。浏览器混乱的给出自己的解释，其中“造就”的罪过，最终降临在WEB开发者身上。</p>
<p>做dotted和dashed的测试是有些枯燥的，不过得出的结论却很有趣且实用，恰当的使用可以提高生产力，算是给某些奇技淫巧提供了科学依据。</p>
<p>测试的方法比较简单，给宽度为0（更紧凑些）的元素定义右边框，类型为dotted或者dashed，边框宽度和元素高度成正比增长，元素左边设置同宽度实线边框做对比，方便测算。</p>
<p>测试的目的主要是了解各浏览器中点线和虚线的计算方式及其他兼容性问题。</p>
<p><strong>TC：<a href="http://www.silentash.com/blog/wp-content/uploads/2009/12/border-style.html">Border-style</a></strong></p>
<p>各浏览器测试截图（上半部分为点线，下半部分为虚线）</p>
<p><strong>Ie6 :</strong><br />
<a href="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-28_234228.png"><img src="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-28_234228.png" alt="border style in ie6" title="border style in ie6" width="391" height="273" class="alignnone size-full wp-image-242" /></a><br />
不知是否开发人员不明白dotted为何物，IE6的1px点线竟然是虚线模样的</p>
<p><strong>Ie7+ :</strong><br />
<a href="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-28_234313.png"><img src="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-28_234313.png" alt="border style in ie7 above" title="border style in ie7 above" width="382" height="266" class="alignnone size-full wp-image-243" /></a><br />
所有IE版本，边框样式与其方向上的长度有关，如纵向边框在其大小和高度成一定关系时消失不见</p>
<p><strong>Firefox 3.5+ :</strong><br />
<a href="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-28_234337.png"><img src="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-28_234337.png" alt="border style in firefox" title="border style in firefox" width="380" height="263" class="alignnone size-full wp-image-244" /></a></p>
<p><strong>Opera 10 :</strong><br />
<a href="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-29_010649.png"><img src="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-29_010649.png" alt="border style in opera" title="border style in opera"  class="alignnone size-full wp-image-245" /></a></p>
<p><strong>Chrome 3.0 :</strong><br />
<a href="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-28_234422.png"><img src="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-28_234422.png" alt="border style  in chrome" title="border style  in chrome" width="382" height="257" class="alignnone size-full wp-image-246" /></a></p>
<p><strong>Safari 4.0 (win) :</strong><br />
<a href="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-28_234514.png"><img src="http://www.silentash.com/blog/wp-content/uploads/2009/12/2009-12-28_234514.png" alt="border style in safari" title="border style in safari" width="383" height="267" class="alignnone size-full wp-image-247" /></a></p>
<p>各浏览器按照其理解去渲染点线和虚线，对比了下，没有完全雷同的渲染方式，时候不早，直接上结论：</p>
<ol>
<li>所有浏览器在边框为1PX表现最为接近（IE6除外），大于1px的非实线千姿百态</li>
<li>除Firefox和Opera，其他浏览器必含头尾点块，且平均分布</li>
<li><strong>IE:点线与虚线均以边框宽度为基准，点线长度必须是其宽度的3倍以上（height>=border-width*3），虚线宽长度必须是其宽度的5倍以上（height>=border-width*5），否则点线和虚线都不会出现。</strong></li>
<li>Firefox:点线以线宽为基准，间隔也为线宽，虚线的间隔则是线宽的3倍，不足则隐藏，所以Firefox的线是密度均衡的，但头尾连接不自然</li>
<li>Chrome在渲染1PX纵向边框时中间有明显粘连，虚线方式在大于1PX时的渲染方式同Safari</li>
<li>Safari和IE条件有点类似 ，点线需 height>border-width*3 ，虚线需 height>border-width*5 ，否则出现一溜实线。</li>
</ol>
<p>结论中比较有用的是第三点，可以作为Hack技巧实现IE6的透明边框，前提是满足虚线框与高度或宽度的一定条件。最简单最实用的一个例子便是广为人知的<strong>Css border方式实现三角</strong></p>
<pre class="chili"><code class="css">
.arrow{
    height:0;
    width:0;
    overflow:hidden;
    /*非IE6支持 transparent ，IE6用dashed边框模拟透明（此时border-width*5&gt;height）
    border-left:5px dashed transparent;
    border-right:5px dashed transparent;
    border-bottom:5px solid #f00;
}
</code></pre>
<p><strong>因dashed比dotted范围广，所以更推荐使用dashed方式模拟IE6下的透明边框。</strong></p>
<hr /><h2>Comments</h2><ul><li><a href="http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw#comment-143">2009年12月29日</a>, <a href='https://www.twitter.com/ivershuo' rel='external nofollow' class='url'>ivershuo</a> writes: RT: <a href="https://www.twitter.com/nunumick" rel="nofollow">@nunumick</a>: New blog post: Dotted&Dashed终极分析及IE6透明边框 http://www.silentash.com/blog/2009/241.html //这个发现甚有意义</li><li><a href="http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw#comment-144">2009年12月29日</a>, <a href='http://www.rainoxu.com' rel='external nofollow' class='url'>Rainoxu</a> writes: 哥哥我第一个来顶你，鸡冻吧~~~嘎嘎</li><li><a href="http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw#comment-145">2009年12月29日</a>, <a href='http://www.silentash.com' rel='external nofollow' class='url'>nunumick</a> writes: @Rainoxu，这是我切换Blog之后的第一帖，很有意义，很鸡冻</li><li><a href="http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw#comment-146">2009年12月29日</a>, <a href='http://www.orzi.org' rel='external nofollow' class='url'>Mick</a> writes: 有用的 IE6 hack</li><li><a href="http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw#comment-148">2009年12月29日</a>, <a href='http://www.silentash.com' rel='external nofollow' class='url'>渔隐</a> writes: Coding Test @<a href="http://www.silentash.com/blog/2009/241.html/comment-page-1#comment-145" rel="nofollow">nunumick</a> :<pre class="chili"><code>alert(&#039;hello world&#039;);</code></pre></li><li><a href="http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw#comment-191">2010年01月22日</a>, <a href='http://adamlu.com/?p=278' rel='external nofollow' class='url'>开发当中遇到的CSS问题 - Hi, I&#8217;m Adam Lu.</a> writes: [...] 6.Css border方式实现三角 .arrow{ height:0; width:0; overflow:hidden; /*非IE6支持 transparent ，IE6用dashed边框模拟透明（此时border-width*5&gt;height） border-left:5px dashed transparent; border-right:5px dashed transparent; border-bottom:5px solid #f00; } 详情请看淘宝UED渔隐的这篇文章http://blog.silentash.com/2009/12/ie6-border-transparent/ [...]</li><li><a href="http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw#comment-314">2010年03月13日</a>, <a href='http://www.zhangxinxu.com/wordpress/' rel='external nofollow' class='url'>张鑫旭</a> writes: “css border方式实现三角”方法广为人知吗？看来，我要学的还有很多啊！</li><li><a href="http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw#comment-726">2010年08月9日</a>, dexbol writes: 有个不方便的地方是：height&gt;=border-width*5 ，这里的"height"是"offsetHeight"</li><li><a href="http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw#comment-727">2010年08月10日</a>, <a href='http://www.webstudy.tk/?p=12' rel='external nofollow' class='url'>webstudy.tk</a> writes: [...] 说明： 以上的测试代码纯粹为了说明原理，所以使用#ffffff白色边框，通过于背景融合来隐藏边框。在实际的操作中，应该使用transparent透明属性，例如border-color:#ff3300 #ff3300 transparent transparent;，这同样会有问题，IE6浏览器不支持transparent透明属性，不过没有关系，就border生成三角技术而言，直接设置对应的透明边框的border-style属性为dotted或是dashed即可解决这一问题，为什么使用dotted和dashed可以修复此问题呢？您有兴趣可以参见默尘的这篇文章Dotted&amp;Dashed终极分析及IE6透明边框。 [...]</li></ul><hr /><small>Copyright &copy; 2008-2010<br /> This feed is for personal, non-commercial use only. <br /> </small>]]></content:encoded>
			<wfw:commentRss>http://blog.silentash.com/2009/12/ie6-border-transparent/?fuckgfw/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
