<?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>ProjeKt D.K &#187; CSS</title>
	<atom:link href="http://blog.punkid.org/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.punkid.org</link>
	<description>Where We ROT!</description>
	<lastBuildDate>Sun, 04 Jul 2010 07:51:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<atom:link rel='hub' href='http://blog.punkid.org/?pushpress=hub'/>
		<item>
		<title>Going Mobile II</title>
		<link>http://blog.punkid.org/2010/03/03/going-mobile-two/</link>
		<comments>http://blog.punkid.org/2010/03/03/going-mobile-two/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 10:10:22 +0000</pubDate>
		<dc:creator>punkid</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[web-developement]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://blog.punkid.org/?p=349</guid>
		<description><![CDATA[还是讨论mobile web design的话题，对之前的Going Mobile做些补充和修正。因为我的blog模板是完全用HTML5重写的，所有不支持HTML5以及CSS的移动设备浏览器全部忽略，我指的是此文只针对iPhone Safari，Google Android Chrome Lite以及Opera Mini/Mobile这些Modern Browsers。 善用&#64;Media规则 Opera Mini/Mobile, Chrome Lite, iPhone Safari都支持&#64;media规则，所以下面这行代码基本上就能搞定这些主流的移动设备浏览器了。 @import url(css/handheld.css) only screen and (max-device-width:480px) 如果你希望为iPhone Safari/Chrome Lite添加独立的样式表的话，加上-webkit prefix就可以了。 @import url(css/handheld_iphone.css) only screen and (-webkit-max-device-width:480px) Viewport的重要性 由于Opera Mobile的默认screen width是850px，而iPhone Safari则是980px。如果你跟我一样，不设定body的宽度，而是让它自适应屏幕宽度的话，你会发现在移动浏览器上你的网页宽度可能远远超过了480px。添加viewport的META到HTML head里能有效避免这个问题。 &#60;meta name=&#34;viewport&#34; content=&#34;width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes&#34; /&#62; 通过width=device-width将网页默认宽度设置为设备屏幕尺寸。 Float and Fixed Positioning float能不用尽量不用，但不等于说float就不能用，至少iPhone Safari，Chrome Lite以及Opera Mini/Mobile对浮动的处理都是很准确的。 [...]]]></description>
			<content:encoded><![CDATA[<p>还是讨论mobile web design的话题，对之前的<a href="http://blog.punkid.org/2009/08/25/going-mobile/" title="Going Mobile">Going Mobile</a>做些补充和修正。因为我的blog模板是完全用HTML5重写的，所有不支持HTML5以及CSS的移动设备浏览器全部忽略，我指的是此文只针对iPhone Safari，Google Android Chrome Lite以及Opera Mini/Mobile这些Modern Browsers。</p>
<h3>善用&#64;Media规则</h3>
<p>Opera Mini/Mobile, Chrome Lite, iPhone Safari都支持<code>&#64;media</code>规则，所以下面这行代码基本上就能搞定这些主流的移动设备浏览器了。</p>
<pre class="css"><span style="color: #a1a100;">@import url(css/handheld.css) only screen and (max-device-width:480px)</span></pre>
<p>如果你希望为iPhone Safari/Chrome Lite添加独立的样式表的话，加上<code>-webkit</code> prefix就可以了。</p>
<pre class="css"><span style="color: #a1a100;">@import url(css/handheld_iphone.css) only screen and (-webkit-max-device-width:480px)</span></pre>
<p><span id="more-349"></span></p>
<h3>Viewport的重要性</h3>
<p>由于Opera Mobile的默认screen width是850px，而iPhone Safari则是980px。如果你跟我一样，不设定<code>body</code>的宽度，而是让它自适应屏幕宽度的话，你会发现在移动浏览器上你的网页宽度可能远远超过了480px。添加<code>viewport</code>的META到HTML head里能有效避免这个问题。</p>
<pre class="xml"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre>
<p>通过<code>width=device-width</code>将网页默认宽度设置为设备屏幕尺寸。</p>
<h3>Float and Fixed Positioning</h3>
<p><code>float</code>能不用尽量不用，但不等于说<code>float</code>就不能用，至少iPhone Safari，Chrome Lite以及Opera Mini/Mobile对浮动的处理都是很准确的。</p>
<p>真正需要避免的是<code>fixed</code>定位，一是浪费了原本就不大的屏幕空间，二是滚动页面时容易导致花屏。</p>
<h3>使用Max-Width</h3>
<p>如果你的图片动辄500px的宽度，在移动设备的浏览器上显示肯定会溢出屏幕，最好的办法是给<code>img</code>加上<code>max-width</code>属性:</p>
<pre class="css">img <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">max-width</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre>
<h3>充分利用好HTML5 input</h3>
<p>HTML5为input加入了很多激动人心的新属性，包括新的<code>type</code>，<code>placeholder</code>以及<code>autofocus</code>。</p>
<h4>新的Input类别</h4>
<p>新加入的input type包括<code>email</code>, <code>url</code>, <code>search</code>&hellip;使用这些<code>type</code>准确定义你的输入框，不仅让代码更语义化，而且在iPhone Safari上也能获得更大的输入便捷。</p>
<p>例如，如果你的<code>input</code>定义为<code>email</code> type:</p>
<pre class="xml"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;email&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre>
<p>在iPhone Safari上点击输入框，弹出的虚拟键盘是这样的:</p>
<p><img src="http://blog.punkid.org/wp-content/uploads/2010/03/input-type-email.png" alt="input-type-email" width="320" height="480" /></p>
<p class="center"><small>图片来自<a href="http://diveintohtml5.org/forms.html" title="A Form of Madness - Dive Into HTML5">Dive into HTML5: A Form of Madness</a></small></p>
<p>最下面的一排按钮包括了email地址常用的<code>&#64;</code>, <code>.</code>符号。</p>
<p>而如果你的<code>input</code>定义为<code>url</code> type的话:</p>
<pre class="xml"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;url&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre>
<p>在iPhone Safari上弹出的虚拟键盘则自动包括了常用的<code>.</code>，<code>/</code>，<code>.com</code>符号。</p>
<p><img src="http://blog.punkid.org/wp-content/uploads/2010/03/input-type-email.png" alt="input-type-email" width="320" height="480" /></p>
<p class="center"><small>图片来自<a href="http://diveintohtml5.org/forms.html" title="A Form of Madness - Dive Into HTML5">Dive into HTML5: A Form of Madness</a></small></p>
<p>长摁<code>.com</code>的话还能在com, org, net中切换，不得不赞叹Apple的工程师对iPhone的细节把握，可惜的是Google Android就没这么聪明了。</p>
<h4>Placeholder属性</h4>
<p><code>placeholder</code>这个新加入的属性可以在<code>input</code>中加入提示性文字，当点击<code>input</code>时该提示性文字则自动隐藏。以往这样的功能是需要依赖于javascript才能实现的。</p>
<p><img src="http://blog.punkid.org/wp-content/uploads/2010/03/input-attr-placeholder.png" alt="input-attr-placeholder" width="400" height="116" /></p>
<p>如上图，加入以下代码，在输入框内会出现<em>(Required, will not be published)</em>的提示性文字。</p>
<pre class="xml"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">placeholder</span>=<span style="color: #ff0000;">&quot;(Required, will not be published)&quot;</span> required <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre>
<p>经测试，iPhone Safari和Chrome Lite都支持该属性。</p>
<h4>Autofocus</h4>
<p>另一个新增加的<code>input</code>是<code>autofocus</code>，目的是在页面加载完后自动聚焦到指定输入框内，这个效果经常在网页账号登陆页面上使用，例如Gmail, WordPress的登陆页面等等。同样，iPhone Safari，Chrome Lite以及Opera Mobile都支持它。</p>
<pre class="xml"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;login&quot;</span> autofocus<span style="color: #000000; font-weight: bold;">&gt;</span></span></pre>
<h3>No Font-Face</h3>
<p><a href="http://www.w3.org/TR/css3-fonts/#the-font-face-rule" title="CSS Fonts Module Level 3">font-face</a>虽然在iPhone Safari，Chrome Lite以及Opera Mobile下都支持，但是以我的blog为例，即使开启了gzip压缩，一个Graublau Web字体还是有38kb。最好还是为移动样式表重新定义下<code>font-family</code>，去掉自定义字体。</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.punkid.org/2009/08/25/going-mobile/" title="Going Mobile (August 25, 2009)">Going Mobile</a> (0)</li>
	<li><a href="http://blog.punkid.org/2010/03/14/digg-into-google-buzz-on-css/" title="Google Buzz产品研究之CSS (March 14, 2010)">Google Buzz产品研究之CSS</a> (2)</li>
	<li><a href="http://blog.punkid.org/2009/04/20/play-with-css3-transitions/" title="好玩的CSS3 Transitions属性 (April 20, 2009)">好玩的CSS3 Transitions属性</a> (1)</li>
	<li><a href="http://blog.punkid.org/2009/08/16/going-html5/" title="Going HTML5 (August 16, 2009)">Going HTML5</a> (3)</li>
	<li><a href="http://blog.punkid.org/2010/07/04/remote-control-mpd-via-remuco-with-your-smartphone/" title="用Remuco实现手机遥控MPD播放 (July 4, 2010)">用Remuco实现手机遥控MPD播放</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.punkid.org/2010/03/03/going-mobile-two/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Going Mobile</title>
		<link>http://blog.punkid.org/2009/08/25/going-mobile/</link>
		<comments>http://blog.punkid.org/2009/08/25/going-mobile/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 08:59:36 +0000</pubDate>
		<dc:creator>punkid</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Gadget]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[handheld]]></category>
		<category><![CDATA[HTC Android]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[M8]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[Nokia]]></category>
		<category><![CDATA[web-developement]]></category>

		<guid isPermaLink="false">http://blog.punkid.org/?p=328</guid>
		<description><![CDATA[还是接着上回的话题吧，感谢leafduo和Lushnis两位很有手机品味的朋友的测试 :D 为什么做这个测试呢？我自己现在绝大部分时间都是在用手机上网，所以自然而然对我的blog进行mobile化改造很必要了。我的Nokia E71上用的是Opera Mini浏览器，它有两个优点，一是对标准（HTML5, CSS）的支持，二是页面经Opera服务器中转压缩处理，省流量。Nokia S60自带的基于webkit的浏览器我也试过，但是既不能解读handheld也不能处理高级点的Media Queries，所以基本上如果单纯从CSS, HTML下手，没法把它从众多桌面浏览器中区分开来，为它设立一个格外的mobile stylesheet。iPhone Safari我也把玩过几次，它对页面的渲染相当好，几乎不需要我格外去设立一个stylesheet了。其他的掌上设备浏览器还包括Android Chrome Lite，Netfront，UCweb等，我都没测试过。 针对各主流手机浏览器设立独立的样式表 因为目前主流的手机屏幕宽度像素都在320px以内，为了让我更好的用E71浏览我自己的blog，我为320宽度屏幕设立了一个独立的样式，把整个容器的宽度都调整到320px，字号也调小到相对大小1.3em。 @import url(css/handheld_320.css.php) handheld; @import url(css/handheld_320.css.php) only screen and (max-device-width:470px); 前面一行是为了target那些支持handheld Media的手机浏览器，后者因为Opera，Safari和Chrome都支持高级的Media Queries，我把最大允许设备屏幕宽度设为470px，这样就能保证在用iPhone/iTouch, HTC G1/G2/Hero以及Nokia的Opera Mini上都能启用handheld_320.css样式表，不用进行水平滚动了。 现在，iPhone， HTC Android，M8都支持横屏模式了，以iPhone为例，横屏时浏览器的窗口宽度是480px，启用handheld_320.css的话未免太浪费水平空间了。所以有必要再对这类横屏模式启用另一个基于480px宽度的stylesheet，我于是再编写了一个handheld_480.css的CSS。 在一个理想的世界中，如果iPhone Safari，Android Chrome Lite这些浏览器支持更进阶的Media Queries的话，直接使用: @import url(css/handheld_480.css.php) only screen and (max-device-width:480px) and (orientation:landscape); 就能保证iPhone Safari，Android Chrome Lite直接启用handheld_480.css了，然而现实是这两款浏览器都不支持orientation，Opera也不例外。所以我只能采取笨一点的方式，将480px宽度的设备默认为iPhone, Android, M8的横屏模式。所以target他们的代码妥协为: @import url(css/handheld_480.css.php) only [...]]]></description>
			<content:encoded><![CDATA[<p>还是接着上回的话题吧，感谢<a href="http://leafduo.com/blog/" title="Leafduo">leafduo</a>和<a href="http://www.mixfog.com/blog" title="Lushnis">Lushnis</a>两位很有手机品味的朋友的测试 :D</p>
<p>为什么做这个测试呢？我自己现在绝大部分时间都是在用手机上网，所以自然而然对我的blog进行mobile化改造很必要了。我的Nokia E71上用的是Opera Mini浏览器，它有两个优点，一是对标准（HTML5, CSS）的支持，二是页面经Opera服务器中转压缩处理，省流量。Nokia S60自带的基于webkit的浏览器我也试过，但是既不能解读<code>handheld</code>也不能处理高级点的Media Queries，所以基本上如果单纯从CSS, HTML下手，没法把它从众多桌面浏览器中区分开来，为它设立一个格外的mobile stylesheet。iPhone Safari我也把玩过几次，它对页面的渲染相当好，几乎不需要我格外去设立一个stylesheet了。其他的掌上设备浏览器还包括Android Chrome Lite，Netfront，UCweb等，我都没测试过。</p>
<h3>针对各主流手机浏览器设立独立的样式表</h3>
<p>因为目前主流的手机屏幕宽度像素都在320px以内，为了让我更好的用E71浏览我自己的blog，我为320宽度屏幕设立了一个独立的样式，把整个容器的宽度都调整到320px，字号也调小到相对大小<code>1.3em</code>。<br />
<span id="more-328"></span></p>
<pre class="css"><span style="color: #a1a100;">@import url(css/handheld_320.css.php) handheld;</span>
<span style="color: #a1a100;">@import url(css/handheld_320.css.php) only screen and (max-device-width:470px);</span></pre>
<p>前面一行是为了target那些支持<code>handheld</code> Media的手机浏览器，后者因为Opera，Safari和Chrome都支持高级的Media Queries，我把最大允许设备屏幕宽度设为470px，这样就能保证在用iPhone/iTouch, HTC G1/G2/Hero以及Nokia的Opera Mini上都能启用<code>handheld_320.css</code>样式表，不用进行水平滚动了。</p>
<p>现在，iPhone， HTC Android，M8都支持横屏模式了，以iPhone为例，横屏时浏览器的窗口宽度是480px，启用<code>handheld_320.css</code>的话未免太浪费水平空间了。所以有必要再对这类横屏模式启用另一个基于480px宽度的stylesheet，我于是再编写了一个<code>handheld_480.css</code>的CSS。</p>
<p>在一个理想的世界中，如果iPhone Safari，Android Chrome Lite这些浏览器支持更进阶的Media Queries的话，直接使用:</p>
<pre class="css"><span style="color: #a1a100;">@import url(css/handheld_480.css.php) only screen and (max-device-width:480px) and (orientation:landscape);</span></pre>
<p>就能保证iPhone Safari，Android Chrome Lite直接启用<code>handheld_480.css</code>了，然而现实是这两款浏览器都不支持<code>orientation</code>，Opera也不例外。所以我只能采取笨一点的方式，将480px宽度的设备默认为iPhone, Android, M8的横屏模式。所以target他们的代码妥协为:</p>
<pre class="css"><span style="color: #a1a100;">@import url(css/handheld_480.css.php) only screen and (device-width:480px);</span></pre>
<p>注意，如果同时引入了针对320px和480px宽度的mobile样式的话，针对320px设备的<code>max-device-width</code>一定要小于480px，否则对于iPhone, Android, M8这类横屏设备，<code>handheld_320.css</code>, <code>handheld_480.css</code>会同时启用。</p>
<p><strong>不幸的是</strong>，这招在iPhone Safari和M8 Opera上都无效，Android上尚未实验。按理说iPhone Safari和Android Chrome Lite是支持<code>device-width</code> media query的，为何不起作用，不解ing&#8230;</p>
<p>另外，由于iPhone Safari会默认启用自动缩放功能，以保证整个页面在可视域范围内。既然我们已经有了<code>handheld_320.css</code>和<code>handheld_480.css</code>样式表，就没必要让它自动缩放了。在<code>&lt;head&gt;</code>里加入这一句HTML代码:</p>
<pre class="xml"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;initial-scale=1.0, maximum-scale=2.0, user-scalable=yes&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre>
<p>这样iPhone Safari的初始化缩放为1（即不缩放），允许的最大缩放倍数为2。</p>
<h3>关于移动样式表的一些CSS Tips</h3>
<p><strong>调整好字号，字体</strong>，我的blog默认启用的是<code>1.6em</code>的大号字体，在小屏幕上看实在有点挥霍空间了，有必要调小几号，我一直都是<code>em</code>字号方式的拥护者，为什么？见<a href="http://mondaybynoon.com/2006/03/13/effective-style-with-em/" title="Effective Style with em">Effective Style with em</a>。</p>
<p><strong>页面一定要留白</strong>，虽然屏幕有320px，480px的宽度，实际上我能用到的可能就300px，460px，为了更好的阅读，页面上下左右各补白10px是有必要的。我直接在父容器<code>wrapper</code>里定义:<code>#wrapper {padding:10px;}</code>就是了。</p>
<p><strong>减少不必要的空白</strong>，桌面浏览可以大胆的增加whitespace，这样看起来更舒适，但是移动设备不一样，过多的使用翻页，滚动条会加速手机的磨损，所以我在做mobile样式处理时，尽量减少过多的空白。</p>
<p><strong>注意浮动和右对齐</strong>，<code>float</code>这个属性一定要注意，特别容易在小屏幕上发生溢出现象，所以能不用<code>float</code>就尽量不用，用的话也得算好容器宽度够不够用，<code>text-align:right</code>更得注意了，在320px以及更小的屏幕上，为了看到水平居右的文字还得拖动水平滚动条是件多么费功夫的事。我在<code>handheld_320.css</code>中几乎把所有右对齐的文字都调整为左对齐了。当然，<code>handheld_480.css</code>我没这么干，大屏幕不用怕 :D</p>
<p><strong>注意不要溢出父容器的box-model</strong>，我在桌面样式上使用了负的<code>margin</code>把文章小标题移到文章一侧，形成marginal aside的样式。</p>
<pre class="css"><span style="color: #6666ff;">.entry</span> h4 <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>margin-<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-200px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre>
<p>但是移动样式上，我回归到常规的标题模式：</p>
<pre class="css"><span style="color: #6666ff;">.entry</span> h4 <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>margin-<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre>
<p>清除浮动和<code>margin</code>，宽度重新设置为<code>100%</code>，这样就不会出现水平滚动条拉动的现象了。</p>
<p><strong>减少不必要的图片和节点</strong>，手机流量费贵啊，3G更贵，除非有wifi，不然sina, pconline这种我从不用手机浏览。所以，没必要的背景图片，修饰图标尽量都给去掉，至于jQuery这类花哨的特效，ajax技术，至少我的Opera Mini用不了，加载了也白费，浪费流量。</p>
<p><strong>Accessibility是个很大的问题</strong>，你用电脑能点的到的我用手机未必点击的到，所以保持代码的语义化，精简化，标准化很重要，多拿手机测试下就知道哪有问题了。</p>
<h3>End</h3>
<p>最后，欢迎各位多用你们的爱机浏览我的blog，iPhone/Android/Palm Pre这类设备咱没钱买，没法完完全全保证我的blog能在这些设备上有好的浏览体验，多多指正，指出问题及解决方案最好。</p>
<p>都09年了，赶紧上移动设备，用mobile技术驱动你的网站吧（如果你也希望我多浏览浏览你的网站的话）。</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.punkid.org/2010/03/03/going-mobile-two/" title="Going Mobile II (March 3, 2010)">Going Mobile II</a> (0)</li>
	<li><a href="http://blog.punkid.org/2009/08/22/css3-media-query-mobile-device-support-testing/" title="呼唤M8, iPhone, HTC Android机友 (August 22, 2009)">呼唤M8, iPhone, HTC Android机友</a> (17)</li>
	<li><a href="http://blog.punkid.org/2009/11/11/access-local-network-share-via-nokia-symsmb/" title="利用symSMB手机访问局域网共享 (November 11, 2009)">利用symSMB手机访问局域网共享</a> (6)</li>
	<li><a href="http://blog.punkid.org/2010/03/14/digg-into-google-buzz-on-css/" title="Google Buzz产品研究之CSS (March 14, 2010)">Google Buzz产品研究之CSS</a> (2)</li>
	<li><a href="http://blog.punkid.org/2010/07/04/remote-control-mpd-via-remuco-with-your-smartphone/" title="用Remuco实现手机遥控MPD播放 (July 4, 2010)">用Remuco实现手机遥控MPD播放</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.punkid.org/2009/08/25/going-mobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>好玩的CSS3 Transitions属性</title>
		<link>http://blog.punkid.org/2009/04/20/play-with-css3-transitions/</link>
		<comments>http://blog.punkid.org/2009/04/20/play-with-css3-transitions/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 15:19:58 +0000</pubDate>
		<dc:creator>punkid</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://blog.punkid.org/?p=313</guid>
		<description><![CDATA[由于写论文的缘故最近经常要切到Windows下，顺便好好玩了下Google Chrome这款webkit engine浏览器，一个星期下来就有彻底投靠Google Chrome的冲动了，就等着Google Chrome的Linux版了。 webkit engine有个很nifty的CSS3私有属性-webkit-transition，有了它可以代替原来很多不得不依靠jQuery这些framework实现的动态效果。 关于这个属性的介绍就不多说了，直接上演示实例吧，用Inspector看下代码就一目了然了。 注：此演示实例只对webkit engine有效，请用最新的Google Chrome, Safari浏览器访问，Linux下可以使用Arora。 Mozilla Firefox 你何时才能解决下linux下的性能问题啊？ Microsoft IE 你何时才能跟上其他浏览器的步伐啊? Opera 你何时才会出Opera Mobile for S60啊? Related posts Going Mobile II (0) 浅谈实现网页交替背景颜色的几种方法 (0) Tips in Aggregate (1) Google Buzz产品研究之CSS (2) Going Mobile (0)]]></description>
			<content:encoded><![CDATA[<p>由于写论文的缘故最近经常要切到Windows下，顺便好好玩了下Google Chrome这款webkit engine浏览器，一个星期下来就有彻底投靠Google Chrome的冲动了，就等着Google Chrome的Linux版了。</p>
<p>webkit engine有个很nifty的CSS3私有属性<a href="http://webkit.org/specs/CSSVisualEffects/CSSTransitions.html" title="CSS Transitions">-webkit-transition</a>，有了它可以代替原来很多不得不依靠jQuery这些framework实现的动态效果。</p>
<p>关于这个属性的介绍就不多说了，直接上<a href="http://punkid.org/glade/CSS3-transitions/index.html" title="Play with CSS3 Transitions">演示实例</a>吧，用Inspector看下代码就一目了然了。</p>
<p>注：此演示实例只对webkit engine有效，请用最新的Google Chrome, Safari浏览器访问，Linux下可以使用Arora。</p>
<p>Mozilla Firefox 你何时才能解决下linux下的性能问题啊？<br />
Microsoft IE 你何时才能跟上其他浏览器的步伐啊?<br />
Opera 你何时才会出Opera Mobile for S60啊?</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.punkid.org/2010/03/03/going-mobile-two/" title="Going Mobile II (March 3, 2010)">Going Mobile II</a> (0)</li>
	<li><a href="http://blog.punkid.org/2007/02/18/sereval-ways-to-make-alter-background/" title="浅谈实现网页交替背景颜色的几种方法 (February 18, 2007)">浅谈实现网页交替背景颜色的几种方法</a> (0)</li>
	<li><a href="http://blog.punkid.org/2008/05/26/tips-in-aggregate/" title="Tips in Aggregate (May 26, 2008)">Tips in Aggregate</a> (1)</li>
	<li><a href="http://blog.punkid.org/2010/03/14/digg-into-google-buzz-on-css/" title="Google Buzz产品研究之CSS (March 14, 2010)">Google Buzz产品研究之CSS</a> (2)</li>
	<li><a href="http://blog.punkid.org/2009/08/25/going-mobile/" title="Going Mobile (August 25, 2009)">Going Mobile</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.punkid.org/2009/04/20/play-with-css3-transitions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tips in Aggregate</title>
		<link>http://blog.punkid.org/2008/05/26/tips-in-aggregate/</link>
		<comments>http://blog.punkid.org/2008/05/26/tips-in-aggregate/#comments</comments>
		<pubDate>Mon, 26 May 2008 15:53:56 +0000</pubDate>
		<dc:creator>punkid</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.punkid.org/?p=216</guid>
		<description><![CDATA[都是些很零碎的tips，涉及到linux, wordpress, css, php, English &#8230; 选择性阅读吧! Douban and PHP 按照之前QQ签名秀的原理把豆瓣的个人广播系统也给提取出来了，效果请见此test页面。 使用方法是把以下代码添加到你的页面里: &#60;script type=&#34;text/javascript&#34; src=&#34;http://punkid.org/glade/douban/request.php?userid=&#60;strong&#62;username&#60;/strong&#62;&#38;numbers=5&#34;&#62;&#60;/script&#62; 其中userid后面跟的是你的豆瓣用户名，numbers后面是显示条目数(最多10条)。至于怎么polish这个douban的miniblog纯粹是你的CSS活。对了，输出编码是UTF-8。 PHP tips: 用addslashes这个函数可以对字符串进行转义。 Linux 1. Tired of emerging the world? emerge $&#40;eix -Iuc --format-compact &#34;&#60;category&#62;/&#60;name&#62;&#34; dev-libs/* &#124; head -n -1&#41; 可以用来更新某一category(例如dev-libs)下的已安装软件。 2. Ape转mp3 emerge shntools 和 mac-port (gentoo-china overlay提供) 后运行: shnsplit -f filename.cue -t &#34;%n - %t&#34; -o &#34;cust [...]]]></description>
			<content:encoded><![CDATA[<p>都是些很零碎的tips，涉及到linux, wordpress, css, php, English &#8230; 选择性阅读吧!</p>
<h3>Douban and PHP</h3>
<p>按照之前<a href="http://punkid.org/qqsign/" title="QQ签名秀">QQ签名秀</a>的原理把豆瓣的个人广播系统也给提取出来了，效果请见此<a href="http://punkid.org/glade/douban/test.html" title="Douban miniblog test page">test页面</a>。</p>
<p>使用方法是把以下代码添加到你的页面里:</p>
<pre class="xml"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://punkid.org/glade/douban/request.php?userid=&lt;strong&gt;</span></span>username<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/strong<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;numbers=5&quot;&gt;&lt;/script&gt;</span></pre>
<p>其中<code>userid</code>后面跟的是你的豆瓣用户名，<code>numbers</code>后面是显示条目数(最多10条)。至于怎么polish这个douban的miniblog纯粹是你的CSS活。对了，输出编码是UTF-8。</p>
<p>PHP tips: 用<a href="http://cn.php.net/manual/en/function.addslashes.php" title="PHP:addslashes">addslashes</a>这个函数可以对字符串进行转义。<br />
<span id="more-216"></span></p>
<h3>Linux</h3>
<h4>1. Tired of emerging the world?</h4>
<pre class="bash">emerge $<span style="color: #7a0874; font-weight: bold;">&#40;</span>eix <span style="color: #660033;">-Iuc</span> <span style="color: #660033;">--format-compact</span> <span style="color: #ff0000;">&quot;&lt;category&gt;/&lt;name&gt;&quot;</span> dev-libs<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-n</span> -<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre>
<p>可以用来更新某一category(例如dev-libs)下的已安装软件。</p>
<h4>2. Ape转mp3</h4>
<p>emerge shntools 和 mac-port (<a href="http://code.google.com/p/gentoo-china-overlay/" title="Gentoo China Overlay">gentoo-china overlay</a>提供) 后运行:</p>
<pre class="bash">shnsplit <span style="color: #660033;">-f</span> filename.cue <span style="color: #660033;">-t</span> <span style="color: #ff0000;">&quot;%n - %t&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;cust ext=mp3 lame --preset extreme - %f&quot;</span> filename.ape</pre>
<p>会根据cue文件对ape进行切割成按<code>tracknumber - trackname</code>命名的mp3文件，不过ID3信息没法保存进去，交给<a href="http://www.musicbrainz.org/" title="Musicbrainz">Musicbrainz</a>搞定吧。</p>
<h4>3. 使用Aria2下载器</h4>
<p>原来用的axel不知何故在我的电脑上经常出现Initialing download就停滞不前的情况，无奈&#8230;换了个稍微大点的Aria2。顺便把Gentoo Mirror的默认下载也换成了aria2。更改make.conf如下:</p>
<pre class="bash"><span style="color: #007800;">FETCHCOMMAND</span>=<span style="color: #ff0000;">&quot;/usr/bin/aria2c -c -s 4 -d <span style="color: #007800;">${DISTDIR}</span> -o <span style="color: #007800;">${FILE}</span> <span style="color: #007800;">${URI}</span>&quot;</span>
<span style="color: #007800;">RESUMECOMMAND</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${FETCHCOMMAND}</span>&quot;</span></pre>
<p>至于在firefox里用flashgot启用aria2下载，在<code>Executable path</code>里填<code>/usr/bin/rxvt</code> (任意虚拟终端，别用xterm就是了，那个启动太慢了)，然后在<code>Command line arguments template</code>里填<code>-e aria2c -s 5 -d [FOLDER] [URL]</code></p>
<h3>WordPress</h3>
<h4>1. 只显示当日评论数</h4>
<p>不明白我的意思的，留个言在到首页看下就知道了，当日有留言的日志会格外用类似于<em>3 comments today</em>方式显示。方法很简单，抽数据而已。修改你的模板的index.php，再最顶端添加:</p>
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
	<span style="color: #000088;">$nowtime</span> <span style="color: #339933;">=</span> current_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'timestamp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d G:i:s'</span><span style="color: #339933;">,</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span><span style="color: #000088;">$nowtime</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d'</span><span style="color: #339933;">,</span><span style="color: #000088;">$nowtime</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #339933;">,</span><span style="color: #000088;">$nowtime</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
<p>然后是修改loop部分:</p>
<pre class="xml"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> if <span style="color: #66cc66;">&#40;</span>have_posts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> while <span style="color: #66cc66;">&#40;</span>have_posts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> : the_post<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;strong<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;?php</span> $today_comments = $wpdb-<span style="color: #000000; font-weight: bold;">&gt;</span></span>get_var(&quot;SELECT COUNT(*) FROM $wpdb-&gt;comments WHERE comment_post_ID = $id AND comment_date &gt;= '$today' AND comment_approved = '1'&quot;); ?&gt;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/strong<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>	
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;entry&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000000; font-weight: bold;">&lt;h2</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;post-&lt;?php the_ID(); ?&gt;</span></span>&quot; class=&quot;entrytitle&quot;&gt;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;&lt;?php the_permalink() ?&gt;</span></span>&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span></span>&quot;&gt;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/h2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;metadata clearfix&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;strong<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;cmt&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> if <span style="color: #66cc66;">&#40;</span>$today_comments <span style="color: #000000; font-weight: bold;">&gt;</span></span> 0) { ?&gt;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;todaycmt&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;&lt;?php the_permalink() ?&gt;</span></span>#comments&quot; title=&quot;Comment on <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span></span>&quot;&gt;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> echo $today_comments; <span style="color: #000000; font-weight: bold;">?&gt;</span></span> Comment<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> if <span style="color: #66cc66;">&#40;</span>$today_comments<span style="color: #000000; font-weight: bold;">&gt;</span></span>1) echo 's'; ?&gt; Today<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #66cc66;">&#125;</span> else <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> comments_popup_link<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'No Comments'</span>, <span style="color: #ff0000;">'1 Comment'</span>, <span style="color: #ff0000;">'% Comments'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/strong<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		...
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
&nbsp;
		...
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> endif; <span style="color: #000000; font-weight: bold;">?&gt;</span></span></pre>
<p>加重部分是关键。</p>
<h4>2. 过滤某category的feed输出</h4>
<p>在模板的function.php里添加这段代码:</p>
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> RssFilter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_feed</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cat'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'-&lt;strong&gt;22&lt;/strong&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
         <span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_posts'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'RssFilter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
<p>其中22为你的category ID。</p>
<h3>CSS</h3>
<p>CSS的代码书写风格我倾向于单行式，用缩进表明元素的从属关系。例如:</p>
<pre class="css"><span style="color: #cc00cc;">#secondary</span> div<span style="color: #6666ff;">.modules</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">40px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#secondary</span> div<span style="color: #6666ff;">.modules</span> a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#888</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#secondary</span> div<span style="color: #6666ff;">.modules</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FF32B3</span><span style="color: #00AA00;">;</span>text-decoration<span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#secondary</span> div<span style="color: #6666ff;">.modules</span> h3 <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#94C742</span><span style="color: #00AA00;">;</span>border-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">dotted</span> <span style="color: #cc00cc;">#94C742</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#secondary</span> div<span style="color: #6666ff;">.modules</span> ul li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>border-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">dashed</span> <span style="color: #cc00cc;">#FF80D0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#secondary</span> div<span style="color: #6666ff;">.modules</span> ul li<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#F0F8E2</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#bottom_wrapper</span> h3 <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FDF262</span><span style="color: #00AA00;">;</span>border-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#FDF262</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#bottom_wrapper</span> div<span style="color: #6666ff;">.modules</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>margin<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>float<span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>position<span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>display<span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#bottom_wrapper</span> div<span style="color: #6666ff;">.modules</span> ul li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.6em</span><span style="color: #00AA00;">;</span>padding<span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>border-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">dotted</span> <span style="color: #cc00cc;">#528F08</span><span style="color: #00AA00;">;</span>overflow<span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#bottom_wrapper</span> div<span style="color: #6666ff;">.modules</span> ul li<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#528F08</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#bottom_wrapper</span> div<span style="color: #cc00cc;">#misc</span> table<span style="color: #6666ff;">.calendar</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>margin-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>border-<span style="color: #993333;">collapse</span><span style="color: #00AA00;">:</span><span style="color: #993333;">separate</span><span style="color: #00AA00;">;</span>border-spacing<span style="color: #00AA00;">:</span><span style="color: #933;">1px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		table<span style="color: #6666ff;">.calendar</span> td <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>text-align<span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		table<span style="color: #6666ff;">.calendar</span> td<span style="color: #6666ff;">.calendar_h</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		table<span style="color: #6666ff;">.calendar</span> td<span style="color: #6666ff;">.today</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#528F08</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		table<span style="color: #6666ff;">.calendar</span> td<span style="color: #6666ff;">.week</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#528F08</span><span style="color: #00AA00;">;</span>color<span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FDF262</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#bottom_wrapper</span> div<span style="color: #cc00cc;">#tags</span> ul li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>padding<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>display<span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>border<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>	
		<span style="color: #cc00cc;">#bottom_wrapper</span> div<span style="color: #cc00cc;">#tags</span> ul li span<span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#bottom_wrapper</span> div<span style="color: #cc00cc;">#tags</span> div <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre>
<p>也许这种单行的方式不利于阅读，但是类似block的书写方式最大的问题是一旦CSS代码上个几百行的，要找到某一行翻页是件很痛苦的事，而单行定义加上适当的缩进即便不看HTML源代码也能对页面结构有个基本的认识。还有就是&#8230;在VIM下用<code>w</code>,<code>b</code>进行整词跳跃是件很惬意的事，即便是单行也能很快的跳跃到需要修改查看的property。</p>
<h3>English</h3>
<h4>1. take with a pinch of salt</h4>
<p>Radiohead的<em>A Wolf at the Door</em>里有句歌词是<em>Take it with the love its given, take it with a pinch of salt, take it to the taxman</em>。</p>
<p>那<em>take it with a pinch of salt</em>真的是抓把盐吗? 真实的意思有点类似于姑且相信，半信半疑的意思，例如<em>Regarding what you said yesterday, I would take it with a pinch of salt</em>意思就是你昨天说的那些我姑且相信吧。</p>
<h4>Tia Dalma and I go way back</h4>
<p>在电影<em>Pirates of the Carribean : The Man&#8217;s Chest</em> (加勒比海盗2:聚魂棺)，Jack船长带着众人去找女巫Tia Dalma时说: <em>No worries, mates. Tia Dalma and I go way back.</em>。我记得当时我看的思路的版本翻译成了<em>伙计们，别担心，Tia Dalma和我待会就回来</em>。这其实是错误的，<em>go back way</em>的意思是表示两人认识很久了，交情很好。</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.punkid.org/2007/04/10/gentoo-notes-part-4/" title="Gentoo 使用笔记 Part 4 (April 10, 2007)">Gentoo 使用笔记 Part 4</a> (4)</li>
	<li><a href="http://blog.punkid.org/2009/03/23/free-sms-notification-on-amule-completed-download/" title="给aMule增加下载完成短信通知功能 (March 23, 2009)">给aMule增加下载完成短信通知功能</a> (9)</li>
	<li><a href="http://blog.punkid.org/2007/02/18/sereval-ways-to-make-alter-background/" title="浅谈实现网页交替背景颜色的几种方法 (February 18, 2007)">浅谈实现网页交替背景颜色的几种方法</a> (0)</li>
	<li><a href="http://blog.punkid.org/2009/04/03/wp-syntax-improvement/" title="改造WP-Syntax (April 3, 2009)">改造WP-Syntax</a> (5)</li>
	<li><a href="http://blog.punkid.org/2008/11/09/why-to-upgrade-to-libgpod-svn-build/" title="Why to Upgrade to Libgpod SVN Build (November 9, 2008)">Why to Upgrade to Libgpod SVN Build</a> (3)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.punkid.org/2008/05/26/tips-in-aggregate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>April 5th is NOT for See Ass Ass</title>
		<link>http://blog.punkid.org/2007/04/02/april-5th-is-not-for-see-ass-ass/</link>
		<comments>http://blog.punkid.org/2007/04/02/april-5th-is-not-for-see-ass-ass/#comments</comments>
		<pubDate>Mon, 02 Apr 2007 07:36:11 +0000</pubDate>
		<dc:creator>punkid</dc:creator>
				<category><![CDATA[Notable]]></category>
		<category><![CDATA[April-5th]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS-Naked-Day]]></category>

		<guid isPermaLink="false">http://blog.punkid.org/2007/04/02/april-5th-is-not-for-see-ass-ass/</guid>
		<description><![CDATA[The CSS Naked Day is coming back! What a CSS Naked Day is? In April 5th, the event participators&#8217; sites will go completely NO STYLE but plain, removing all of the CSS. Seems like quite interesting and alternative, i&#8217;d like to get NUDE with these crazy guys. The purpose is let you know how important [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.punkid.org/wp-content/uploads/2007/04/nocss.png" alt="No CSS" class="floatleft" />The <a href="http://naked.dustindiaz.com/" title="CSS Naked Day">CSS Naked Day</a> is coming back! What a CSS Naked Day is? In April 5th, the event participators&#8217; sites will go completely <strong>NO STYLE</strong> but plain, removing all of the CSS.</p>
<p>Seems like quite interesting and alternative, i&#8217;d like to get NUDE with these crazy guys. The purpose is let you know how important and magical the CSS is for site decorating,as well the reason why we should write semantic codes.</p>
<p><a href="http://naked.dustindiaz.com/#signup" title="Join Us">Join us</a> if you wanna save your bandwidth a little bit more. NO <em>SEE ASS ASS</em> (CSS) !</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.punkid.org/2007/02/18/sereval-ways-to-make-alter-background/" title="浅谈实现网页交替背景颜色的几种方法 (February 18, 2007)">浅谈实现网页交替背景颜色的几种方法</a> (0)</li>
	<li><a href="http://blog.punkid.org/2009/04/20/play-with-css3-transitions/" title="好玩的CSS3 Transitions属性 (April 20, 2009)">好玩的CSS3 Transitions属性</a> (1)</li>
	<li><a href="http://blog.punkid.org/2008/05/26/tips-in-aggregate/" title="Tips in Aggregate (May 26, 2008)">Tips in Aggregate</a> (1)</li>
	<li><a href="http://blog.punkid.org/2010/03/03/going-mobile-two/" title="Going Mobile II (March 3, 2010)">Going Mobile II</a> (0)</li>
	<li><a href="http://blog.punkid.org/2009/08/25/going-mobile/" title="Going Mobile (August 25, 2009)">Going Mobile</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.punkid.org/2007/04/02/april-5th-is-not-for-see-ass-ass/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Bugs on Modern Browsers</title>
		<link>http://blog.punkid.org/2007/03/17/bugs-on-modern-browsers/</link>
		<comments>http://blog.punkid.org/2007/03/17/bugs-on-modern-browsers/#comments</comments>
		<pubDate>Sat, 17 Mar 2007 13:04:32 +0000</pubDate>
		<dc:creator>punkid</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[clearfix]]></category>
		<category><![CDATA[fixed-position]]></category>
		<category><![CDATA[Gecko]]></category>
		<category><![CDATA[Konqueor]]></category>

		<guid isPermaLink="false">http://blog.punkid.org/2007/03/17/bugs-on-modern-browsers/</guid>
		<description><![CDATA[While I&#8217;m making a new wordpress design for Rockaby, I found Mozilla Firefox and even Konqueror Browser have some problems or misunderstanding on CSS compliance. Fixed Position Fucked Up When Scrolling in Gecko Engine Browsers I like the idea of keeping the footer area always visible on the bottom of the browser window, so i [...]]]></description>
			<content:encoded><![CDATA[<p>While I&#8217;m making a new wordpress design for <a href="http://rockaby.net" title="Rockaby">Rockaby</a>, I found Mozilla Firefox and even Konqueror Browser have some problems or misunderstanding on CSS compliance.</p>
<h3>Fixed Position Fucked Up When Scrolling in Gecko Engine Browsers</h3>
<p>I like the idea of keeping the footer area always visible on the bottom of the browser window, so i did it to the Rockaby&#8217;s theme, I applied <code>fixed</code> position rule into the footer div like this.</p>
<pre>
#footer  {height:104px;width:100%;color:#fff;font-size:1.3em;background:url(img/footer.png) repeat-x ;position:fixed;bottom:0;z-index:8;}
</pre>
<p>The footer should always stand on the bottom of the browser window in spite of scrolling. I knew IE6 couldnt understand <code>fixed</code> position rule. I&#8217;ve tested it in IE7,Konqueror,Opera&#8230;all work well,except Firefox. When the page loads much information and objects, scrolling quickly may fuck up the whole page, lets see the 2 pictures below .<br />
<span id="more-33"></span><br />
<img src="http://photo1.yupoo.com/20070317/183403_403463253_xocliikv.jpg" alt="Mozilla Bug" width="420" height="301" border="0" /></p>
<p>It looks quite well as the footer standing on the bottom of the visible area in Firefox browser window.</p>
<p><img src="http://photo1.yupoo.com/20070317/183405_1924525188_qgkriivm.jpg" alt="Mozilla Bug" width="420" height="301" border="0" /></p>
<p>Then I just scroll the window, ooh, it really fucked up. And it wont be okay unless I minimize it or switch to another tab. The browser takes too much time to render the fixed object. I&#8217;ve tried it in FF1.5 and FF2.0, Flock, SeaMonkey and K-Meleon (all in Gecko Engine), no luck.</p>
<p>This is a bug in Gecko Engine Browser, and no solution <abbr title="As Far As I Know">AFAIK</abbr>. All you can do is make sure that the page doesnt load a LOT of objects or give up the fixed position idea. Fortunately, the Mozilla developers have noticed this problem,I tried the latest nightly build of Firefox 3 (a3pre),it works much better (though still far from perfect).</p>
<p>Anyway, I dont feel like to give up the fixed position idea so far.</p>
<h3>Clearfix doesnt works well in :after pseudo element in Konqueror (KHTML)</h3>
<p>The well-known clearfix CSS tip is used to close the floating objects. I added this rule to make drop cap typographical effects for the first letter in each blog entry.</p>
<pre>.entry > p:first-child:first-letter { font: 30px Times,Georgia,Verdana,'Lucida Grande',Sans-Serif; text-transform: uppercase; float: left; margin-right: 8px; padding-top: 4px }
</pre>
<p>To close the floating, and make sure the floating paragraph wont mess up the others. I applied this clearfix rule into the first paragraph&#8217;s <code>:after</code> pseudo</p>
<pre>
.entry > p:first-child:after {content:".";display:block;height:0;clear:both;visibility:hidden;text-indent:-9999em;}
</pre>
<p>It works well in Firefox and Opera, but Konqueror maybe misunderstand it. See the image below, the content of the <code>:after</code> pesudo element is visible!</p>
<p><img src="http://photo1.yupoo.com/20070317/192044_1738624070_rcmbbmvx.jpg" alt="clearfix-bug" width="420" height="224" border="0" /></p>
<p>Thanx to Thomas&#8217;s <a href="http://thomas.tanreisoftware.com/?p=11" title="CSS hacks series">CSS hacks series</a> and the other browsers&#8217; bad CSS3 compliance. We&#8217;ll be able to &#8216;fix&#8217; it by a pure CSS3 way.</p>
<pre>
html:not(:nth-child(1)) ... { ... }
</pre>
<p>This rule is only recognized by Konqueror,thx to its fantastic support on CSS3 selectors. So i applied this rule:</p>
<pre>
html:not(:nth-child(1)) .entry > p:first-child:after {content:""}
</pre>
<p>To give a null content to the <code>:after</code> pseudo element. And please notice, actually the content is still there, but becuz its null, so nothing we can see.</p>
<p>And definitely you can use this hack to apply specific rules on Konqueror at hand (before other browsers give support on <code>:not</code> and <code>:nth-child</code> pseudo)</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.punkid.org/2007/02/18/sereval-ways-to-make-alter-background/" title="浅谈实现网页交替背景颜色的几种方法 (February 18, 2007)">浅谈实现网页交替背景颜色的几种方法</a> (0)</li>
	<li><a href="http://blog.punkid.org/2009/04/20/play-with-css3-transitions/" title="好玩的CSS3 Transitions属性 (April 20, 2009)">好玩的CSS3 Transitions属性</a> (1)</li>
	<li><a href="http://blog.punkid.org/2008/05/26/tips-in-aggregate/" title="Tips in Aggregate (May 26, 2008)">Tips in Aggregate</a> (1)</li>
	<li><a href="http://blog.punkid.org/2010/03/03/going-mobile-two/" title="Going Mobile II (March 3, 2010)">Going Mobile II</a> (0)</li>
	<li><a href="http://blog.punkid.org/2009/08/25/going-mobile/" title="Going Mobile (August 25, 2009)">Going Mobile</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.punkid.org/2007/03/17/bugs-on-modern-browsers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>浅谈实现网页交替背景颜色的几种方法</title>
		<link>http://blog.punkid.org/2007/02/18/sereval-ways-to-make-alter-background/</link>
		<comments>http://blog.punkid.org/2007/02/18/sereval-ways-to-make-alter-background/#comments</comments>
		<pubDate>Sat, 17 Feb 2007 16:05:38 +0000</pubDate>
		<dc:creator>punkid</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[交替背景]]></category>

		<guid isPermaLink="false">http://blog.punkid.org/2007/02/18/sereval-ways-to-make-alter-background/</guid>
		<description><![CDATA[WordPress 的评论模板部分都会定义一个$oddcomment函数用来实现评论的样式交替变换，采取交替样式可以使列表有一定分区度，便于浏览。我稍稍总结了下，分别通过javascript, php和CSS三种方式进行实现，其中CSS实现方法还几乎处于理想状态，仅供参考。 实现方法之Javascript篇 假设我们有个id名为 list 的无序列表ul，其下有5项item (li)。我们可以用getElementById和getElementsByTagName先找到这些item，然后通过for循环筛选出奇数项并赋予class值。再通过CSS定义该奇数项class样式从而达到交替样式的目的。javascript代码如下: function alterItem() { var list=document.getElementById('list'); var items=list.getElementsByTagName('li'); for (var i=0;i&#60;items.length;i++) { if(i%2==0) items[i].className='odd'; } } window.onload=alterItem; 最后用通过CSS定义 .odd样式就行了。 实现方法之PHP篇 此方法来源于WordPress论坛的这篇日志。我曾经在PP的sidenotes部分就是用这种方法实现交替背景的(WP的comment部分已经有oddcomment函数了，无须再费周折)，我直接照搬原来PP theme里的sidenotes部分代码。 &#60;?php query_posts('category_name=sidenotes&#038;showposts=3'); ?&#62; &#60;?php while (have_posts()) : the_post(); ?&#62; &#60;div id="p&#60;?php the_ID(); ?&#62;" class="&#60;?=($i%2)?"even":"odd";$i++;?&#62;"&#62; &#60;a href="&#60;?php the_permalink() ?&#62;" rel="bookmark" title="Permanent Link to &#60;?php strip_tags(the_title()); ?&#62;" class="title"&#62;&#60;?php [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress 的评论模板部分都会定义一个<var>$oddcomment</var>函数用来实现评论的样式交替变换，采取交替样式可以使列表有一定分区度，便于浏览。我稍稍总结了下，分别通过<a href="#javascript_way" title="Javascript Way">javascript</a>, <a href="#php_way" title="PHP Way">php</a>和<a href="#css_way" title="CSS Way">CSS</a>三种方式进行实现，其中CSS实现方法还几乎处于理想状态，仅供参考。</p>
<h3 id="javascript_way">实现方法之Javascript篇</h3>
<p>假设我们有个id名为 list 的无序列表ul，其下有5项item (li)。我们可以用<var>getElementById</var>和<var>getElementsByTagName</var>先找到这些item，然后通过for循环筛选出奇数项并赋予class值。再通过CSS定义该奇数项class样式从而达到交替样式的目的。javascript代码如下:</p>
<pre>
 function alterItem() {
 var list=document.getElementById('list');
 var items=list.getElementsByTagName('li');
 for (var i=0;i&lt;items.length;i++) {
   if(i%2==0)
   items[i].className='odd';
   }
 }

 window.onload=alterItem;
</pre>
<p>最后用通过CSS定义 .odd样式就行了。<br />
<span id="more-16"></span></p>
<h3 id="php_way">实现方法之PHP篇</h3>
<p>此方法来源于<a href="http://wordpress.org/support/topic/1148?replies=20#post-27911" title="Alternating comment backgrounds">WordPress论坛的这篇日志</a>。我曾经在PP的sidenotes部分就是用这种方法实现交替背景的(WP的comment部分已经有<var>oddcomment</var>函数了，无须再费周折)，我直接照搬原来PP theme里的sidenotes部分代码。</p>
<pre>
&lt;?php query_posts('category_name=sidenotes&#038;showposts=3'); ?&gt;
     &lt;?php while (have_posts()) : the_post(); ?&gt;
     &lt;div id="p&lt;?php the_ID(); ?&gt;" <strong>class="&lt;?=($i%2)?"even":"odd";$i++;?&gt;"</strong>&gt;
     &lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link to &lt;?php strip_tags(the_title()); ?&gt;" class="title"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
     &lt;?php the_content(); ?&gt;
     &lt;/div&gt;
&lt;?php endwhile;&gt;
</pre>
<p>注意其中加粗部分，先在模板文件顶部插入如下代码<code>&lt;?$i;?&gt;</code>，然后在class里加入这句判断语句就够了<code>&lt;?=($i%2)?"even":"odd";$i++;?&gt;</code>。学过C语言的都知道这是个if..else判断语句的缩写形式&#8211; <code>If (Expression) ? true : false</code>，如果满足表达式，则执行? 部分，否则执行 : 部分。也就是说，满足 $i%2等于0，即$i为偶，则赋予class为even值，然后$i 加一，滚动到下一item上进行第二次判断。</p>
<h3 id="css_way">实现方法之CSS篇</h3>
<p>CSS2有个<var>:nth-child</var>的选择器，这是个非常非常强大的选择器，你可以定义<code>Element:nth-child(3)</code>来找到为其父元素下的第三个子元素，你也可以定义<code>Element:nth-child(odd) </code>或者<code>Element:nth-child(even)</code> 来查找其父元素下的奇偶子元素，甚至可以用<code>Element:nth-child(3n+2)</code> 来找到其父元素下的第3n+2个元素( n=0,1,2&#8230;)。通过CSS方法定义那太简单了!</p>
<pre>
ul#list li:nth-child(odd) {background:#000;color:#fff}

ul#list li:nth-child(even) {background:#fff;color:#000;}
</pre>
<p>不过，这么好的方法&#8230;目前只有linux下的konqueror浏览器支持(注:Konqueror是目前唯一100%通过<a href="http://www.css3.info/selectors-test/" title="CSS Selectors Suites">CSS3所有选择器测试</a>的浏览器)，好在Opera已经开始<a href="http://my.opera.com/dstorey/blog/show.dml/701902" title="Upcoming CSS3 support in Opera">落实支持该选择器的工作</a>了。</p>
<p>我个人比较喜欢这种cutting edge的方式! 如果你想让你的网站/blog做的更先锋的话就用这种方式吧!</p>
<p><strong>顺带说句</strong>: 其实linux下的konqueror是款相当棒的浏览器，他们对CSS的支持一向都是做的最棒的(目前还有个opacity没解决)，连<a href="http://www.css3.info/preview/multiple-backgrounds/" title="Multiple-Backgrounds">multiple-backgrounds</a>他们都支持了!</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.punkid.org/2008/05/26/tips-in-aggregate/" title="Tips in Aggregate (May 26, 2008)">Tips in Aggregate</a> (1)</li>
	<li><a href="http://blog.punkid.org/2007/10/05/bring-back-feedburner-counts-image-to-earth-in-china/" title="让Feedburner的计数器重新显示 (October 5, 2007)">让Feedburner的计数器重新显示</a> (4)</li>
	<li><a href="http://blog.punkid.org/2009/04/03/wp-syntax-improvement/" title="改造WP-Syntax (April 3, 2009)">改造WP-Syntax</a> (5)</li>
	<li><a href="http://blog.punkid.org/2009/04/20/play-with-css3-transitions/" title="好玩的CSS3 Transitions属性 (April 20, 2009)">好玩的CSS3 Transitions属性</a> (1)</li>
	<li><a href="http://blog.punkid.org/2007/10/12/powered-with-jquery/" title="决定启用jQuery (October 12, 2007)">决定启用jQuery</a> (1)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.punkid.org/2007/02/18/sereval-ways-to-make-alter-background/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
