<?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>子叶：子乌的叶子 &#187; 技术</title>
	<atom:link href="http://sheneyan.com/blog/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://sheneyan.com/blog</link>
	<description>指穷于为薪，火传也，不知其尽也。---《养生主》</description>
	<lastBuildDate>Tue, 17 Jan 2012 03:05:10 +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>『子乌书简』的建立及更新日志</title>
		<link>http://sheneyan.com/blog/2011/01/logs-for-my-books-site/</link>
		<comments>http://sheneyan.com/blog/2011/01/logs-for-my-books-site/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 06:30:27 +0000</pubDate>
		<dc:creator>子乌</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[日记]]></category>
		<category><![CDATA[calibre]]></category>
		<category><![CDATA[kindle]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[读书]]></category>

		<guid isPermaLink="false">http://sheneyan.com/blog/?p=2228</guid>
		<description><![CDATA[<h4>建站缘由</h4>
<p>建立子站<a href="http://book.zi5.me" title="子乌书简">子乌书简</a>的原意只是为了方便自己利用kindle自带的3G网络下载自己收集的电子书并与友人共享，所以最开始只是利用了<a href="http://calibre-ebook.com/">电子书收藏软件Calibre</a>和<a href="wiki.mobileread.com/wiki/Calibre2opds">Calibre的html化插件Calibre2Opds</a>在<a href="https://www.dropbox.com">云存储服务Dropbox</a>上建立了一个静态网站。</p>
<p>但是在用了一两天之后发现一个问题：静态网站无法提供搜索服务，当书籍的数量达到一定量级时，寻找需要的书就会变成一个比较吃力的事情，尤其是在我们河蟹的帝国，dropbox这种庸俗的服务是不允许直接使用的，需要一定的技术手段才能达到目标，但是也并不太方便，速度上也有一定影响。</p>
<p>好吧，如果我没好奇地去看一下calibre真实使用的数据库结构[......]</p><p class='read-more'><a href='http://sheneyan.com/blog/2011/01/logs-for-my-books-site/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<h4>建站缘由</h4>
<p>建立子站<a href="http://book.zi5.me" title="子乌书简">子乌书简</a>的原意只是为了方便自己利用kindle自带的3G网络下载自己收集的电子书并与友人共享，所以最开始只是利用了<a href="http://calibre-ebook.com/">电子书收藏软件Calibre</a>和<a href="wiki.mobileread.com/wiki/Calibre2opds">Calibre的html化插件Calibre2Opds</a>在<a href="https://www.dropbox.com">云存储服务Dropbox</a>上建立了一个静态网站。</p>
<p>但是在用了一两天之后发现一个问题：静态网站无法提供搜索服务，当书籍的数量达到一定量级时，寻找需要的书就会变成一个比较吃力的事情，尤其是在我们河蟹的帝国，dropbox这种庸俗的服务是不允许直接使用的，需要一定的技术手段才能达到目标，但是也并不太方便，速度上也有一定影响。</p>
<p>好吧，如果我没好奇地去看一下calibre真实使用的数据库结构的话，我可能会使用另外一种方式来实现我自己的搜索：那就是所谓的小偷程序，我得把<strong>我自己</strong>的网站的内容偷到<strong>我自己</strong>的另一个网站上去……</p>
<p>在研究calibre2opds的实现方式时，发现它读取的数据库是sqlite，好了，接下来一切都简单了，我按照calibre2opds建立网站的大概结构建立了<a href="http://book.zi5.me/">子乌书简</a>，即<a href="http://book.zi5.me/">book.zi5.me</a>。</p>
<p>对我来说，现在更新书籍的工作很简单，找到我想看的书，导入到calibre中，转换出所需的类型，利用calibre内置引擎到豆瓣或别的地方更新一下相关的元数据（标题、作者、系列、封面、简介等），然后接下来就交给dropbox去搞定了。当dropbox数据提交完毕后，网站会自动从dropbox下载数据库到本地，而书籍封面、电子书文件都还存放在dropbox上，我的站只是作为我放在dropobx上的电子书和伟大帝国屁民之间的桥梁而已。</p>
<p>介绍完毕。</p>
<h4>建站日志</h4>
<ul>
<li>1、2011-2-20，dropbox再次提示流量超限-_-，再改一次看看是不是数据库的原因；2、修改了在线阅读时书籍内部超链接可能出错的bug(目前的修正方法还是不太满意，做个标记，以后有机会看看能否完善)；</li>
<li>2011-2-16，顺手实现字母排序查询～～；</li>
<li>2011-2-8，dropbox提示我流量超限，把我的public目录给suspend了……为此修改了书籍下载的方式；</li>
<li style='color:red;'>2011-1-25，增加epub格式在线阅读功能（简单快捷键：左、右、回车）；</li>
<li>2011-1-23，显示豆瓣评分（因为速度原因，暂时只在详细页面显示，并隐藏评价数小于10人的书籍评分）；</li>
<li>2011-1-22，将排序列表完全放出；</li>
<li>2011-1-22，完成功能：pdf格式文件直接通过邮件发送到kindle上（可选择是否需要转换为azw格式）</li>
<li>2011-1-21，完成rss功能；</li>
<li>2011-1-20，修改了多作者的书籍无法在kindle下载的问题；</li>
<li><del>2011-1-xx，实现浏览数和下载数统计（独立数据库）</del>(因为下载的实现做了修改，下载统计暂时停止，有空再改)</li>
<li>2011-1-xx，修改了mobi格式书籍无法在kindle下载的问题；</li>
</ul>
<h4>待完成功能</h4>
<ul>
<li>考虑加入豆瓣id登录进行评论（顺便实现底下的报告功能）(2011-2-16:考虑实现豆瓣的收藏、已读、评论、笔记功能)；</li>
<li>考虑实现单ip限制下载功能（比如单ip10秒内只能下载一本书籍，稍微降低一点对dropbox的影响）</li>
<li>提交自制电子书/提交想看的电子书(可能放弃)；</li>
<li>放出tag功能（需要整理现有书籍的tag）；</li>
<li>(已完成)<del>考虑是否实现打分功能或支持从豆瓣采集相关的分数；</del></li>
<li>考虑实现错误报告（文件无法下载、文件无法打开、文件格式不好看，等等等等）；</li>
<li>系列的优化（实现一书多系列）；</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sheneyan.com/blog/2011/01/logs-for-my-books-site/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>js版圣诞树</title>
		<link>http://sheneyan.com/blog/2010/12/js-christmas-tree/</link>
		<comments>http://sheneyan.com/blog/2010/12/js-christmas-tree/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 14:09:01 +0000</pubDate>
		<dc:creator>子乌</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[christmas]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://sheneyan.com/blog/?p=2210</guid>
		<description><![CDATA[<div><a href="http://sheneyan.com/blog/wp-content/uploads/2010/12/tree.png" rel="lightbox[2210]" rel="shadowbox[sbpost-2210];player=img;" title="tree"><img src="http://sheneyan.com/blog/wp-content/uploads/2010/12/tree-300x235.png" alt="" title="tree" width="300" height="235" class="alignnone size-medium wp-image-2211" /></a></div>
<p>在网上瞎逛时，看到<a href="http://www.fucklenovo.com/wxp/archives/2010/12/20/2061">1kb大小的圣诞树</a>js代码，看了一下效果，相当地赞，不过需要html5支持（我猜的，看代码要用到canvas），有兴趣地可以看看<a href="http://js1k.com/2010-xmas/demo/856">demo</a>和<a href="http://www.romancortes.com/blog/how-i-did-the-1kb-christmas-tree/">原理解释</a>。现在暂时没有兴趣研究代码，不过先收藏着也不错。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&#160;&#160;HTML</div><span style="color: #009900;">&#60;!doctype html&#62;</span>
<span style="color: #009900;">&#60;<span style="color: #000000; font-weight: bold;">html</span>&#62;</span>
    <span style="color: #009900;">&#60;<span style="color: #000000; font-weight: bold;">head</span>&#62;</span>
        <span style="color: #009900;">&#60;<span style="color: #000000; font-weight: bold;">title</span>&#62;</span>JS1k, 1k demo submission [856]<span style="color: #009900;">&#60;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&#62;</span>
        <span style="color: #009900;">&#60;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&#34;utf-8&#34;</span> <span style="color: #66cc66;">/</span>&#62;[......]</span></div></div><p class='read-more'><a href='http://sheneyan.com/blog/2010/12/js-christmas-tree/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<div><a href="http://sheneyan.com/blog/wp-content/uploads/2010/12/tree.png" rel="lightbox[2210]" rel="shadowbox[sbpost-2210];player=img;" title="tree"><img src="http://sheneyan.com/blog/wp-content/uploads/2010/12/tree-300x235.png" alt="" title="tree" width="300" height="235" class="alignnone size-medium wp-image-2211" /></a></div>
<p>在网上瞎逛时，看到<a href="http://www.fucklenovo.com/wxp/archives/2010/12/20/2061">1kb大小的圣诞树</a>js代码，看了一下效果，相当地赞，不过需要html5支持（我猜的，看代码要用到canvas），有兴趣地可以看看<a href="http://js1k.com/2010-xmas/demo/856">demo</a>和<a href="http://www.romancortes.com/blog/how-i-did-the-1kb-christmas-tree/">原理解释</a>。现在暂时没有兴趣研究代码，不过先收藏着也不错。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;!doctype html&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>JS1k, 1k demo submission [856]<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
        <span style="color: #009900;">&lt;canvas <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;c&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>canvas&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
            var b = document.body;
            var c = document.getElementsByTagName('canvas')[0];
            var a = c.getContext('2d');
            document.body.clientWidth; // fix bug in chrome.
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
// start of submission //
M=Math;Q=M.random;J=[];U=16;T=M.sin;E=M.sqrt;for(O=k=0;x=z=j=i=k<span style="color: #009900;">&lt;<span style="color: #cc66cc;">200</span>;<span style="color: #66cc66;">&#41;</span>with<span style="color: #66cc66;">&#40;</span>M<span style="color: #66cc66;">&#91;</span>k<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">=</span>k?c.cloneNode<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>:c<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #000066;">height</span><span style="color: #66cc66;">=</span>k?<span style="color: #cc66cc;">32</span>:W<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">446</span>;with<span style="color: #66cc66;">&#40;</span>getContext<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'2d'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>if<span style="color: #66cc66;">&#40;</span>k&gt;</span>10|!k)for(font='60px Impact',V='rgba(';I=i*U,fillStyle=k?k==13?V+'205,205,215,.15)':V+(147+I)+','+(k%2?128+I:0)+','+I+',.5)':'%23cca',i<span style="color: #009900;">&lt;<span style="color: #cc66cc;">7</span>;<span style="color: #66cc66;">&#41;</span>beginPath<span style="color: #66cc66;">&#40;</span>fill<span style="color: #66cc66;">&#40;</span>arc<span style="color: #66cc66;">&#40;</span>U-i<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">3</span>,<span style="color: #cc66cc;">24</span>-i<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>,k<span style="color: #66cc66;">==</span><span style="color: #cc66cc;">13</span>?<span style="color: #cc66cc;">4</span>-<span style="color: #66cc66;">&#40;</span>i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>:<span style="color: #cc66cc;">8</span>-i++,<span style="color: #cc66cc;">0</span>,M.PI*<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;else <span style="color: #000066;">for</span><span style="color: #66cc66;">&#40;</span>;x<span style="color: #66cc66;">=</span>T<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>,y<span style="color: #66cc66;">=</span>Q<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>*<span style="color: #cc66cc;">2</span>-<span style="color: #cc66cc;">1</span>,D<span style="color: #66cc66;">=</span>x*x+y*y,B<span style="color: #66cc66;">=</span>E<span style="color: #66cc66;">&#40;</span>D-x<span style="color: #66cc66;">/</span>.9-<span style="color: #cc66cc;">1.5</span>*y+<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>,R<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">67</span>*<span style="color: #66cc66;">&#40;</span>B+<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>*<span style="color: #66cc66;">&#40;</span>L<span style="color: #66cc66;">=</span>k<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">9</span>+.8<span style="color: #66cc66;">&#41;</span>&gt;</span>&gt;1,i++<span style="color: #009900;">&lt;W;<span style="color: #66cc66;">&#41;</span>if<span style="color: #66cc66;">&#40;</span>D&lt;<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>beginPath<span style="color: #66cc66;">&#40;</span>strokeStyle<span style="color: #66cc66;">=</span>V+R+<span style="color: #ff0000;">','</span>+<span style="color: #66cc66;">&#40;</span>R+B*L&gt;</span>&gt;0)+',40,.1)'),moveTo(U+x*8,U+y*8),lineTo(U+x*U,U+y*U),stroke();for(y=H=k+E(k++)*25,R=Q()*W;P=3,j<span style="color: #009900;">&lt;H;<span style="color: #66cc66;">&#41;</span>J<span style="color: #66cc66;">&#91;</span>O++<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">=</span><span style="color: #66cc66;">&#91;</span>x+<span style="color: #66cc66;">=</span>T<span style="color: #66cc66;">&#40;</span>R<span style="color: #66cc66;">&#41;</span>*P+Q<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>*<span style="color: #cc66cc;">6</span>-<span style="color: #cc66cc;">3</span>,y+<span style="color: #66cc66;">=</span>Q<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>*U-<span style="color: #cc66cc;">8</span>,z+<span style="color: #66cc66;">=</span>T<span style="color: #66cc66;">&#40;</span>R-<span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span>*P+Q<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>*<span style="color: #cc66cc;">6</span>-<span style="color: #cc66cc;">3</span>,j<span style="color: #66cc66;">/</span>H*<span style="color: #cc66cc;">20</span>+<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>j+<span style="color: #66cc66;">=</span>U<span style="color: #66cc66;">&#41;</span>&gt;</span>H<span style="color: #ddbb00;">&amp;Q()&gt;.8?Q(P=9)*4:0)&gt;&gt;1]}setInterval(function G(m,l){A=T(D-11);</span>if(l)return(m[2]-l[2])*A+(l[0]-m[0])*T(D);a.clearRect(0,0,W,W);J.sort(G);for(i=0;L=J[i++];a.drawImage(M[L[3]+1],207+L[0]*A+L[2]*T(D)&gt;&gt;0,L[1]&gt;&gt;1)){if(i==2e3)a.fillText('Merry Xmas!',U,345);if(!(i%7))a.drawImage(M[13],((157*(i*i)+T(D*5+i*i)*5)%W)&gt;&gt;0,((113*i+(D*i)/60)%(290+i/99))&gt;&gt;0);}D+=.02},1)
// end of submission //
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://sheneyan.com/blog/2010/12/js-christmas-tree/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>修改插件Flickr Gallery以支持缓存</title>
		<link>http://sheneyan.com/blog/2010/11/modifing-flickr-gallery-for-cache/</link>
		<comments>http://sheneyan.com/blog/2010/11/modifing-flickr-gallery-for-cache/#comments</comments>
		<pubDate>Sat, 13 Nov 2010 00:56:04 +0000</pubDate>
		<dc:creator>子乌</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[日记]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[wordpress插件]]></category>

		<guid isPermaLink="false">http://sheneyan.com/blog/?p=1795</guid>
		<description><![CDATA[<p>原本使用插件<a href="http://wordpress.org/extend/plugins/flickr-rss/">FlickrRSS</a>来实现flickr页面的照片缓存加展示，不过那个插件的下载似乎存在一些奇怪的问题（照片经常更新失败，而且是特定的照片更新失败，诡异地都让我快认为国外也有功夫网了……），于是再次开始寻找合适的flickr展示用插件的路程。不过可能是因为我用的关键字不对或者是老外对缓存flickr觉得没有必要（一点都不了解中国国情），基本上没看到合适的带缓存功能的flickr wordpress插件，那就只能自己改了。</p>
<p>随便找了个插件，<a href="http://wordpress.org/extend/plugins/flickr-gallery/">Flickr Gallery</a>（也不算随便找的啦，至少这个插件支持3.0.1……），研究了半天，增加了一个自动缓存文件（只缓存一次，毕竟是缓存个人照片，[......]</p><p class='read-more'><a href='http://sheneyan.com/blog/2010/11/modifing-flickr-gallery-for-cache/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>原本使用插件<a href="http://wordpress.org/extend/plugins/flickr-rss/">FlickrRSS</a>来实现flickr页面的照片缓存加展示，不过那个插件的下载似乎存在一些奇怪的问题（照片经常更新失败，而且是特定的照片更新失败，诡异地都让我快认为国外也有功夫网了……），于是再次开始寻找合适的flickr展示用插件的路程。不过可能是因为我用的关键字不对或者是老外对缓存flickr觉得没有必要（一点都不了解中国国情），基本上没看到合适的带缓存功能的flickr wordpress插件，那就只能自己改了。</p>
<p>随便找了个插件，<a href="http://wordpress.org/extend/plugins/flickr-gallery/">Flickr Gallery</a>（也不算随便找的啦，至少这个插件支持3.0.1……），研究了半天，增加了一个自动缓存文件（只缓存一次，毕竟是缓存个人照片，基本上不存在更新的问题）的函数并更新了所有调用的地方（这个插件的代码并不好看，耦合度很高，只能一处处寻找修改的地方）。</p>
<p>修改的地方太多，不一一列出具体内容，只给自己一个备忘，避免下次直接升级废掉我几个小时的劳动成果（主要是替换好累啊）：</p>
<p>0 说明一下我调用到的flickr gallery内容：我只使用了flickr gallery的最基本的gallery功能，而且没使用设定大小功能，如果使用了size的话，可能会出现问题（因为我没修改相应的代码……）。</p>
<p>1 phpFlickr.php，这个是插件的核心文件，处理了flickr的交互方法，在这个文件中增加了一个自动缓存的方法：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;PHP</div><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* get cached image photo url by sheneyan 2010.11.13*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> getCachedPhotoURL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$photoURL</span><span style="color: #339933;">,</span><span style="color: #000088;">$type</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;photo&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//这里我写死了缓存的绝对路径，请自行设定或者修改其配置页面，记得设置写权限</span>
	<span style="color: #000088;">$CACHE_PATH</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'/xxx/yyy/zzz/blog/wp-content/cache'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//md5文件名，我实在是懒得截取文件名……</span>
	<span style="color: #000088;">$cachedFileName</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$photoURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.jpg'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//缓存文件绝对路径，以md5首字建子目录，如果你的照片超多，可考虑多层子目录（还是一样……我懒……）</span>
	<span style="color: #000088;">$cachedFilePath</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$CACHE_PATH</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cachedFileName</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$cachedFileName</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//缓存文件访问链接</span>
	<span style="color: #000088;">$cachedFileURL</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/blog/wp-content/cache/'</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cachedFileName</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$cachedFileName</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//如果媒体类型是视频，则直接返回原来的链接</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span><span style="color: #339933;">==</span><span style="color: #0000ff;">'video'</span><span style="color: #009900;">&#41;</span><span style="color: #b1b100;">return</span> <span style="color: #000088;">$photoURL</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//如果缓存文件不存在</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cachedFileName</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//读取远程文件并保存到本地（呃，临时就想到这个写法，有更简单的吗？）</span>
		<span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cachedFilePath</span><span style="color: #339933;">,</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$photoURL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//返回缓存路径</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$cachedFileURL</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span></pre></div></div>

<p>2 flickr-gallery.php，寻找所有的img src，将src复制一份，重命名为rel，src里面的链接套上<code style='color:green'>$phpFlickr-&gt;getCachedPhotoURL(....)</code>，rel里的链接套上<code style='color:green'>$phpFlickr-&gt;getCachedPhotoURL(....,'medium')</code>(<span class='notes'>为了放大用，如果打算看更大的图，把medium改成large</span>)，如果有设定<code style='color:green'>class="&lt;?php echo $photo['media'] ?&gt;"</code>的，则记得rel里面不要调用自定义函数(<span class='notes'>因为flickr gallery的原本的lightbox效果是直接取得原有缩略图的地址进行修改获得中等大小图片地址的，而缩略图地址已经被我md5，所以必须再提供一个新的地址供放大用，才使用了属性rel，并需要修改相应的js——见底下</span>)。</p>
<p>3 flightbox/jquery.flightbox.js 修改其中的一处：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;Javascript</div><pre class="javascript" style="font-family:monospace;">		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> options.<span style="color: #660066;">size_callback</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">||</span> $calling.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;video&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$image.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span> $calling.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/_[stm]\./g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span></pre></div></div>

<p>改为：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;Javascript</div><pre class="javascript" style="font-family:monospace;">		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> options.<span style="color: #660066;">size_callback</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">||</span> $calling.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;video&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$calling.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;video&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				$image.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span> $calling.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;rel&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/_[stm]\./g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
				$image.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span> $calling.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;rel&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span></pre></div></div>

<p>其他的地方可改可不改（因为我目前只调用了最简单的flickr gallery shortcode，所以其他地方不影响到实际效果，以后有更新时再修改这篇备忘～）</p>
<p>这样就搞定了，效果见：<a href="http://sheneyan.com/blog/flickr">我的照片</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://sheneyan.com/blog/2010/11/modifing-flickr-gallery-for-cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PSD/HTML转换：简洁优雅的CSS3网页布局</title>
		<link>http://sheneyan.com/blog/2010/10/psdhtml-conversion-elegant-and-simple-css3-web-layout/</link>
		<comments>http://sheneyan.com/blog/2010/10/psdhtml-conversion-elegant-and-simple-css3-web-layout/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 01:43:37 +0000</pubDate>
		<dc:creator>子乌</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[翻译]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[布局]]></category>
		<category><![CDATA[教程]]></category>

		<guid isPermaLink="false">http://sheneyan.com/blog/?p=1613</guid>
		<description><![CDATA[<ul>
<li>作者： <a href="http://twitter.com/hatchergraphics" title="Eric Hoffman">Eric Hoffman</a></li>
<li>译者：<a href="http://sheneyan.com/blog">Sheneyan(子乌)</a></li>
<li>时间：2010-10-13</li>
<li>英文原文：<a href="http://sixrevisions.com/tutorials/web-development-tutorials/psdhtml-conversion-elegant-and-simple-css3-web-layout/">PSD/HTML Conversion: Elegant and Simple CSS3 Web Layout</a></li>
</ul>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-21_elegant_css3_layout_ld_img.jpg" width="550" height="250" /></div>
<p><em>这是系列教程的第二部分。<a href="http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/">第一部分</a>设计了一个简洁优雅的部落格设计。在开始这个教程之前你可以先看看第一部分以获得更大收获。</em></p>
<p><span id="more-3987"></span></p>
<h4>《简洁优雅的部落格网页布局教程》系列</h4>
<p>这篇教程是一个系列的第二集。这个部分(<strong>第二集</strong>)展示了如何利用第一集中建立的PSD设计制作一个HTML/CSS网页模板。</p>
<ul>
<li><strong>第一集：</strong><a href="http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/">使用Photoshop建立一个简洁优雅的部落格网页布局</a></li>
<li><strong>第二集：</strong><a href="http://sheneyan.com/blog/2010/10/psdhtml-conversion-elegant-and-simple-css3-web-layout/">PSD/HTML转换：简[......]</a></li></ul><p class='read-more'><a href='http://sheneyan.com/blog/2010/10/psdhtml-conversion-elegant-and-simple-css3-web-layout/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<ul>
<li>作者： <a href="http://twitter.com/hatchergraphics" title="Eric Hoffman">Eric Hoffman</a></li>
<li>译者：<a href="http://sheneyan.com/blog">Sheneyan(子乌)</a></li>
<li>时间：2010-10-13</li>
<li>英文原文：<a href="http://sixrevisions.com/tutorials/web-development-tutorials/psdhtml-conversion-elegant-and-simple-css3-web-layout/">PSD/HTML Conversion: Elegant and Simple CSS3 Web Layout</a></li>
</ul>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-21_elegant_css3_layout_ld_img.jpg" width="550" height="250" /></div>
<p><em>这是系列教程的第二部分。<a href="http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/">第一部分</a>设计了一个简洁优雅的部落格设计。在开始这个教程之前你可以先看看第一部分以获得更大收获。</em></p>
<p><span id="more-3987"></span></p>
<h4>《简洁优雅的部落格网页布局教程》系列</h4>
<p>这篇教程是一个系列的第二集。这个部分(<strong>第二集</strong>)展示了如何利用第一集中建立的PSD设计制作一个HTML/CSS网页模板。</p>
<ul>
<li><strong>第一集：</strong><a href="http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/">使用Photoshop建立一个简洁优雅的部落格网页布局</a></li>
<li><strong>第二集：</strong><a href="http://sheneyan.com/blog/2010/10/psdhtml-conversion-elegant-and-simple-css3-web-layout/">PSD/HTML转换：简洁优雅的CSS3网页布局</a></li>
</ul>
<h4>最终成果</h4>
<p>单击下面的最终成果预览图来查看<a href="http://demos.sixrevisions.com/2010/08/27/index.html">在线演示</a>。因为我们使用了部分CSS3，该示例在所有浏览器上看起来不会完全一致。</p>
<div><a href="http://demos.sixrevisions.com/2010/08/27/index.html"><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-22_final_result_preview.jpg" width="550" height="313" alt="Final Result" /></a></div>
<p><a class="more-link" href="http://demos.sixrevisions.com/2010/08/27/index.html">查看示例</a></p>
<h4>创建基础文件</h4>
<p><span class="tutorial-number">1</span>我们要做的第一件事就是建立文件和文件夹。在你的计算机上建立一个新文件夹，命名为<code>letterpress</code>。这是我们的工作目录。</p>
<p><span class="tutorial-number">2</span>在文件夹<code>letterpress</code>下创建2个文件夹，命名为<code>images</code>和<code>styles</code>。</p>
<p><span class="tutorial-number">3</span>打开你最喜欢的HTML/CSS编辑器(如Dreamweaver或Notepad++)并创建一个HTML文档。命名为<code>index.html</code>或别的什么适合的名称。将这个HTML文档保存在文件夹<code>letterpress</code>下。</p>
<p><span class="tutorial-number">4</span>创建一个样式文档并命名为<code>style.css</code>（或其他的名称）。保存至<code>styles</code>文件夹下。</p>
<h4>基本HTML</h4>
<p><span class="tutorial-number">5</span>下面的代码来自于<code>index.html</code>。使用了常用的HTML标记。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Letterpress<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content-type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=ISO-8859-1&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;style.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<h4>PSD切片</h4>
<p><span class="tutorial-number">6</span>现在打开Photoshop并打开我们之前依照教程的<a href="http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop">第一部分</a>制作的PSD文档。</p>
<p><span class="tutorial-number">7</span>除了下列图层外其他全部隐藏：</p>
<ul>
<li>Datebg 和 shadow</li>
<li>Headerdivider</li>
<li>Navbarbg</li>
<li>Logo</li>
<li>Sidebar</li>
<li>Sidebar divider</li>
<li>Background</li>
<li>Widgetbg</li>
<li>Footerbg</li>
<li>Image</li>
<li>imagebg</li>
</ul>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-01_hide_layers.jpg" width="548" height="796" alt="PSD切片" /></div>
<p><span class="tutorial-number">8</span>使用矩形选框工具(M)选中代表活动页的书签。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-02_select_bookmark.jpg" width="549" height="388" alt="PSD切片" /></div>
<p><span class="tutorial-number">9</span>复制选中部分并执行 编辑 &gt; 合并拷贝(Ctrl/Cmd + Shift + C)。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-03_edit_copy_merged.jpg" width="549" height="514" alt="PSD切片" /></div>
<p><span class="tutorial-number">10</span>打开一个新的Photoshop文档(Ctrl/Cmd + N)；不要修改画板大小，因为它自动匹配在你剪贴板中内容的尺寸（在这个例子中，是那个书签。）</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-04_copy_paste_newdoc.jpg" width="549" height="338" alt="Slice the PSD " /></div>
<p><span class="tutorial-number">11</span>单击 Ctrl/Cmd + V (编辑 &gt; 黏贴 的键盘快捷键)将复制内容黏贴到新的Photoshop文档中。</p>
<p><span class="tutorial-number">12</span>选择 文件 &gt; 存储为Web和设备所用格式，将新文档以JPG格式存储至<code>images</code>文件夹。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-05_save_for_web.jpg" width="549" height="657" alt="PSD切片 " /></div>
<h4>撰写HTML标记</h4>
<p>我通常会先实现HTML（包括class和id），然后才写CSS来设置站点样式。这样我就不必前后来回切换，可以保证我的工作顺畅进行。我们先给我们的设计中不同的部分编码，然后再来设置它们的样式。</p>
<h4>容器</h4>
<p><span class="tutorial-number">13</span>创建一个id为<code>container</code>的div；它会用于容纳除了页脚之外的所有元素。通过这种方法我们可以在接下来的时候很容易地将其置为居中。</p>
<p><span class="tutorial-number">14</span>为logo创建一个div并将网站的logo图片插入其中。你可以用我们之前讨论过的相同的方式从PSD样板中将LOGO切出来，或插入你自己的LOGO(推荐)。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- CONTAINER --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;container&quot;</span>&gt;</span>
  <span style="color: #808080; font-style: italic;">&lt;!-- LOGO --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logo&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;images/logo.jpg&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;348&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;60&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logo&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-06_logo.jpg" width="550" height="189" alt="PSD切片 " /></div>
<h4>导航栏</h4>
<p><span class="tutorial-number">15</span>接下来，我们创建导航栏。使用一个无序号列表，将每个导航栏链接加为列表项。 给第一个列表项设置id<code>firstlink</code>，顺便给当前链接加上一个背景图(从PSD中切出的书签)。还要加上分割线。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- NAVIGATION BAR --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;navigationbar&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;firstlink&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Home<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>About<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Archives<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Contact<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dividerheader&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p class="notes">子乌注：完全没必要使用一个独立div来放分割线，设置navigationbar的背景即可，下同。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-07_unordered_list_main_nav.jpg" width="550" height="249" alt="导航栏" /></div>
<h4>侧边栏</h4>
<p><span class="tutorial-number">16</span>创建新的div，设置id=<code>sidebar</code>。</p>
<p><span class="tutorial-number">17</span>插入一个表单，带有元素<code>input type=&quot;text&quot;</code>。</p>
<p><span class="tutorial-number">18</span>改变文本框元素的默认值为<code>Search</code>，<code>size</code>属性设为 29 (29个字符)，给它绑定一个Javascript事件监听器，这样当文本框元素获得焦点或失去焦点时，会触发函数<code>clearText()</code>。</p>
<p><strong>注:</strong>强烈建议<strong>静悄悄地写javascript</strong>。因为我们在这个教程中的重点不是JavaScript，我决定在行内实现函数。<em>请使用不引人注目的JavaScript</em>(<span class="notes">子乌注：不太明白作者的意思……</span>)。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;">onFocus=&quot;clearText(this)&quot; onBlur=&quot;clearText(this);&quot;</pre></div></div>

<p>这就是在搜索文本框中隐藏或显示“Search”文本的函数内容。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
function clearText(field)
{
  if (field.defaultValue == field.value) field.value = '';
  else if (field.value == '') field.value = field.defaultValue;
}
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>下面是我们关于侧边栏和搜索表单的HTML标记。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- SIDEBAR --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sidecolumn&quot;</span>&gt;</span>
  <span style="color: #808080; font-style: italic;">&lt;!-- SEARCH --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;searchform&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Search&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;29&quot;</span> <span style="color: #000066;">onFocus</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clearText(this)&quot;</span> <span style="color: #000066;">onBlur</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clearText(this)&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dividersidebar&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-08_searchbar.jpg" width="550" height="291" alt="侧边栏" /></div>
<h4>最近文章和最新回复</h4>
<p><span class="tutorial-number">19</span>创建两个div；设置id为<code>recentposts</code>和<code>latestcomments</code>。</p>
<p><span class="tutorial-number">20</span>在他们之间加入一个分割线。输入一些示例内容包括添加标题和段落元素。双箭头引用(&raquo;)的HTML字符编码为<code>&amp;#187;</code>。你可以在这看到一个完整的html字符编码表：<a href="http://www.zytrax.com/tech/web/entities.html" title="html entities and codings - www.zytrax.com">here</a>. 我使用<code>&lt;li&gt;</code>标签来区分每个回复/文章名，待会再设置他们的样式。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- recent posts --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;recentposts&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>recent posts<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span><span style="color: #ddbb00;">&amp;#187;</span> lorem ipsum post<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span><span style="color: #ddbb00;">&amp;#187;</span> another post<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span><span style="color: #ddbb00;">&amp;#187;</span> i'm just writing things<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dividersidebar&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- latest comments --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;latestcomments&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>latest comments<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span><span style="color: #ddbb00;">&amp;#187;</span> &quot;blah blah blah...&quot;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span><span style="color: #ddbb00;">&amp;#187;</span> &quot;blah blah blah...&quot;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span><span style="color: #ddbb00;">&amp;#187;</span> &quot;blah blah blah...&quot;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-09_recentlatest_comments.jpg" width="550" height="596" alt="最近文章和最新回复" /></div>
<h4>侧边栏网页横幅</h4>
<p>现在每个部落格都有广告区域，我们为什么不放呢？</p>
<p><span class="tutorial-number">21</span>在div <code>#sidebar</code>，添加另一个容纳所有网页横幅的div。</p>
<p><span class="tutorial-number">22</span>前两个网页横幅需要设置id <code>adrightfirst</code> (右边的)和 <code>adleftfirst</code> (左边的)。因为我们的空间只够在一行放两个广告，你必须给每行加个换行。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- advertising --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;adrightfirst&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;adleftfirst&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;adright&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;adleft&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;adright&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;adleft&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;adright&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;adleft&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- end of sidebar --&gt;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-10_ads_html.jpg" width="549" height="1137" alt="侧边栏网页横幅" /></div>
<h4>文章</h4>
<p>回到部落格文章的标记部分。</p>
<p><span class="tutorial-number">23</span>创建三个div：<code>date1</code>、<code>datetext1</code>和<code>post1</code>。</p>
<p><span class="tutorial-number">24</span>添加日期(日期使用<code>&lt;h1&gt;</code>，月份使用<code>&lt;p&gt;</code>)，标题(使用<code>&lt;h1&gt;</code>)，文章元数据(使用<code>&lt;h2&gt;</code>)还有一些内容(使用<code>&lt;p&gt;</code>)。</p>
<p class="notes">子乌注：从语义的角度上来讲，日期使用h1、文章标题使用h1都是有问题的，因为在一个页面中应该只有唯一一个顶级标题，建议用字体大小来设定日期的格式，而文章标题使用h2级别的标题来标明——它应该是除了部落格名称之外级别第二高的标题（可多个），另外，div不该用id来标识，这样问题很多，应该直接用class来标识，前面的广告部分也存在类似的问题。</p>
<p><span class="tutorial-number">25</span>复制整个文章div，黏贴到下面(创建另一篇部落格文章条目)。在两篇文章间插入分割线。别忘了修改数字(<code>date1</code> 改为 <code>date2</code>)。</p>
<p class="notes">子乌注：前面已经说过了，这样做的话没太大意义，除非要针对文章进行脚本处理或别的操作，别设置无意义的id！</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- date one --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;date1&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;datetext&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>13<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>apr<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- post one --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post1&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>i enjoy reading six revisions<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>by eric hoffman <span style="color: #ddbb00;">&amp;nbsp;&amp;middot;&amp;nbsp;</span> 1223 comments <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;images/snowboard.jpg&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;snowboard&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;margin: 5px 0px 5px 0px&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span> &quot;lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&quot;lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">i</span>&gt;</span>continue reading... <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">i</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dividerpost&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- date two --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;date2&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;datetext&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>12<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>apr<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- post two --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post2&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>who likes obama?<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>by george bush <span style="color: #ddbb00;">&amp;nbsp;&amp;middot;&amp;nbsp;</span> 0 comments <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
&nbsp;
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;images/snowboard.jpg&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;snowboard&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;margin: 5px 0px 5px 0px&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span> &quot;lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&quot;lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">i</span>&gt;</span>continue reading... <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">i</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- end of container --&gt;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-11_posts_html.jpg" width="549" height="1635" alt="文章" /></div>
<h4>页脚部件</h4>
<p><span class="tutorial-number">26</span>创建div，id=<code>footerwidgets</code>。在其内部放置一个新的div，id=<code>footerwidgettext</code>。插入三个不同id的div。例如 <code>footerwidgettextfirst</code>, <code>footerwidgettextmiddle</code>,依此类推。使用不同的id以使得可以设置不同的margin，所以我们不使用class。</p>
<p class="notes">子乌注：设置不同的margin不是不使用class的原因……不过这里影响不太大。另外，id的命名真的很烂，我知道你是示例，那也不该这么写啊……</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- FOOTERWIDGETS --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footerwidget&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footerwidgettext&quot;</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- WIDGET ONE --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footerwidgettextfirst&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Widget title <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Karl Aloys zu Fürstenberg (1760-1799) was a soldier in the Austrian service. He achieved the rank of Field Marshal, and died at the Battle of Stockach. The third son of a cadet branch of the Fürstenberg, at his birth his chances of inheriting the family title of Fürst zu Fürstenberg ...<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- WIDGET TWO --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footerwidgettextmiddle&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Widget title <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Karl Aloys zu Fürstenberg (1760-1799) was a soldier in the Austrian service. He achieved the rank of Field Marshal, and died at the Battle of Stockach. The third son of a cadet branch of the Fürstenberg, at his birth his chances of inheriting the family title of Fürst zu Fürstenberg ...<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- WIDGET THREE --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footerwidgettextlast&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Widget title <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Karl Aloys zu Fürstenberg (1760-1799) was a soldier in the Austrian service. He achieved the rank of Field Marshal, and died at the Battle of Stockach. The third son of a cadet branch of the Fürstenberg, at his birth his chances of inheriting the family title of Fürst zu Fürstenberg ...<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- END OF FOOTER WIDGETS --&gt;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-12_footer_widgets.jpg" width="549" height="526" alt="页脚部件" /></div>
<h4>页脚</h4>
<p>我们接下来做个简单的页脚节点。</p>
<p><span class="tutorial-number">27</span>和div<code>#footerwidgets</code>一样，div<code>#footer</code>设为100%宽度，不过文本将和其余内容对齐(居中)。这就是我们为什么要在其中创建另一个id=<code>footertext</code>的div。将页脚内容添加进<code>#footertext</code>。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- FOOTER --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footertext&quot;</span>&gt;</span>
<span style="color: #ddbb00;">&amp;copy;</span> 2010 Eric Hoffman. All rights reserved.
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- END OF FOOTER --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-13_html_finished.jpg" width="549" height="2235" alt="Footer" /></div>
<p>上面就是全部的标记内容，接下来是CSS。</p>
<h4>撰写CSS</h4>
<p>我们完成了HTML，现在来处理我们的样式。</p>
<p><span class="tutorial-number">28</span>首先的首先：打开开始时创建的文件<code>style.css</code>。确保你的HTML文件正确链接到这个文件。</p>
<h4>重置CSS</h4>
<p><span class="tutorial-number">29</span>首先，我们使用一个简单的CSS将我们的样式进行重置。我建议你针对CSS重置进行更进一步的阅读以充分了解它的优势；<a href="http://sixrevisions.com/css/css-tips/css-tip-1-resetting-your-styles-with-css-reset/" title="Resetting Your Styles with CSS Reset - sixrevisions.com">CSS Reset</a> 是个不错的开始。简单起见，我这里只使用了选择器 <code>*</code>。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;">* {
  margin:0;
  padding:0;
}</pre></div></div>

<h4>Body背景和 @font-face</h4>
<p><span class="tutorial-number">30</span>下一步，改变body背景为我们PSD样板中的杂色蓝色背景。学习将其从PSD样板中切出来(我也将它放到可下在的原文件包中——<code>background.jpg</code>).</p>
<p><span class="tutorial-number">31</span>我们还使用了CSS3元素<code>text-shadow</code>。<code>0</code>是x轴偏移量，<code>1px</code>是y轴偏移量，<code>2px</code>是模糊效果而<code>#555</code>是阴影颜色。<code>@font-face</code>允许我们内嵌一个非网页安全的字体以使所有访客可以看到我们制作网页时的样子。你可以在 <a href="http://sixrevisions.com/css/font-face-guide/">The Essential Guide to @font-face</a>详细了解<code>@font-size</code>。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../images/background.jpg&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#555</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
&amp;<span style="color: #cc00cc;">#64</span><span style="color: #00AA00;">;</span>font-face <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Museo Slab 500&quot;</span><span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;http://hatchergraphics.com/MuseoSlab-500.otf&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h4>包装/导航</h4>
<p><span class="tutorial-number">32</span>我们现在创建一个容器作为包装以使我们可以轻易地将我们的设计居中。我喜欢制作精确到像素的设计，所以我选择了固定宽度布局。如果你想看看其他布局样式，你可以看看<a href="http://sixrevisions.com/web_design/a-guide-on-layout-types-in-web-design/">A Guide on Layout Types in Web Design</a>。为了居中容器，只要使用<code>margin: 0 auto;</code> (<span class="notes">子乌注：删掉了一个ad XD</span>)。</p>
<p><span class="tutorial-number">33</span>给导航栏设置样式。<code>#firstlink</code>是当前链接。如果你想扩展设计并添加所有的四个页面，你必须修改列表的id。例如，如果我现在在“About”页面，列表项About必须有id<code>firstlink</code>。为了居中背景图，使用 <code>background-position: center;</code>。</p>
<p class="notes">子乌注：嗯……用class的话更利于语义，因为id不应该随意变更……</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#container</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">890px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navigationbar</span> <span style="color: #00AA00;">&#123;</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: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">50px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">80px</span> <span style="color: #933;">390px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">650px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navigationbar</span> ul li <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Museo Slab 500&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navigationbar</span> ul li 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;">#FFF</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">74px</span> <span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navigationbar</span> ul li 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;">#DBDBDB</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#firstlink</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../images/linkbg.jpg&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">74px</span> <span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-14_background_navigation.jpg" width="550" height="579" alt="包装/导航" /></div>
<h4>Logo/分割线</h4>
<p><span class="tutorial-number">34</span>Logo的高度和宽度取决于你的网站名称。我们的“Letterpress”字体为65pt(Photoshop中)，高度60px而宽度为348px。</p>
<p><span class="tutorial-number">35</span>接下来设置分割线的样式。你可以使用2px高的空白div、span或者设置你的标题的样式以让其有2px高的底部边框。我使用了和文章分割线一样的背景图。</p>
<p class="notes">前面提到过了，完全没必要使用独立div来做分割线，无意义的元素，无意义的流量消耗。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#logo</span> <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>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">60px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">348px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#dividerheader</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../images/dividerpost.jpg&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-x</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">890px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-15_1px_divider.jpg" width="549" height="214" alt="Logo/分割线" /></div>
<h4>侧边栏</h4>
<p><span class="tutorial-number">36</span>下一步，设置侧边栏的样式。因为部落格div会有500px宽，而我喜欢在文章和侧边栏之间有些留白，我设定侧边栏的宽度为250px。</p>
<p><span class="tutorial-number">37</span>设置分割线的样式，<code>recentposts</code>和<code>latestcomments</code>以及搜索栏。这里我们会使用另一个CSS3属性：<code>border-radius</code>。这意味着我们可以只使用CSS创建圆角边角。不幸的是这个功能并不被所有浏览器支持，所以它不会在所有浏览器下看着都圆圆的(例如IE8及以下版本)。</p>
<p><span class="tutorial-number">38</span>给所有的广告元素设置样式以确保算数正确(他们的宽度加起来不能超过250px)。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#sidecolumn</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#2c7c88</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#116678</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#dividersidebar</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../images/dividersidebar.jpg&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#recentposts</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#latestcomments</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;">10px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
  word-wrap<span style="color: #3333ff;">:break-</span>word<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#recentposts</span> ul a<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#latestcomments</span> ul 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;">#FFF</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Trebuchet MS&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">13px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">22px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#searchform</span> <span style="color: #00AA00;">&#123;</span>
  -moz-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
  -webkit-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Trebuchet MS&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">13px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#adrightfirst</span> <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;">right</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">-1px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">31px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#adleftfirst</span> <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>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-1px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">31px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#adright</span> <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;">right</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">-1px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#adleft</span> <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>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-1px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#adright</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#adleft</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#adrightfirst</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#adleftfirst</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#f6f6f6</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#e7e7e7</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">117px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">117px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#adright</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#adleft</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#adrightfirst</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#adleftfirst</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#e7e7e7</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#dbdbdb</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-16_sidebar_partly_styled.jpg" width="549" height="1092" alt="侧边栏" /></div>
<h4>文章</h4>
<p><span class="tutorial-number">39</span>再下来：文章。我们将创建2个文章div：一个叫做<code>post1</code>另一个叫做<code>post2</code>。</p>
<p><span class="tutorial-number">40</span>接下来我们对日期做同样的处理。如我之前提及的，两个文章div有500px宽。通过margin来定位他们，设置<code>padding-left</code>为-90px。<code>position</code>设为<code>absolute</code>。</p>
<p><span class="tutorial-number">41</span>创建另一个分割线，但这次它将和文章一样宽。</p>
<p class="notes">子乌注：从下面的css来看就明白这种情况下用id来设css是多么的傻……</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#post1</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;">#FFF</span><span style="color: #00AA00;">;</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>
  <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: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">90px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#post2</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;">#FFF</span><span style="color: #00AA00;">;</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>
  <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: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">525px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">90px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#dividerpost</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../images/dividerpost.jpg&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-x</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">495px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#date1</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../images/datebg.jpg&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</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>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">123px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">90px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#date2</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../images/datebg.jpg&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</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>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">123px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-90px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">90px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#datetext</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">46px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">38.5px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">31px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#datetext</span> p <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Museo Slab 500&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-transform</span><span style="color: #00AA00;">:</span><span style="color: #993333;">uppercase</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#datetext</span> h1 <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Museo Slab 500&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">35px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">22px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-17_posts.jpg" width="549" height="999" alt="Posts" /></div>
<h4>页脚部件</h4>
<p>快好了！</p>
<p><span class="tutorial-number">42</span>页脚部件：正如你在HTML那看到的，页脚和页脚部件都放在容器外，所以他们不会被我们的包装限定为890px宽。它们俩都是100%宽。</p>
<p><span class="tutorial-number">43</span>添加背景、高度(240px)，以及顶部margin。我新增了个<code>#footerwidget</code> div，一个文本div，以及其他三个放不同部件的div。给它们设置相同的样式，唯一的区别就是它们的边框和margin。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#footerwidget</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../images/widgetbg.jpg&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">110px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">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: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#footerwidgettext</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">890px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#footerwidgettextfirst</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">dotted</span> <span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</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>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">165px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">22px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">276px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#footerwidgettextlast</span> <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>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">165px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">22px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">594px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">276px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#footerwidgettextmiddle</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">dotted</span> <span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</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>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">165px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">22px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">297px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">276px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-18_footer_widgets.jpg" width="549" height="332" alt="页脚部件" /></div>
<h4>页脚</h4>
<p><span class="tutorial-number">44</span>页脚的高度是44px。设置背景。属性<code>position</code>设置为<code>absolute</code>以使它永远在底部。类似页脚部件，我为文本创建了另一个div以让我能够让它们居中并让它和主体内容区域对齐。这里我使用了<code>margin: auto 0;</code>属性来居中它。top-margin设为10px。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#footer</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../images/footer.jpg&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-x</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">44px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">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: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#footertext</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">44px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #993333;">auto</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">890px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-19_footer_border.jpg" width="549" height="152" alt="页脚" /></div>
<p><span class="tutorial-number">45</span>接下来的样式会应用到不同的元素上；我只是将它们放到一起而已。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#recentposts</span> h1<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#latestcomments</span> h1<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#footerwidgettextfirst</span> h1<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#footerwidgettextmiddle</span> h1<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#footerwidgettextlast</span> h1 <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Georgia&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">18px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#post1</span> h1<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#post2</span> h1 <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Georgia&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#post1</span> h2<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#post2</span> h2 <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Trajan Pro&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">18px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#post1</span> p<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#post2</span> p <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Trebuchet MS&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">13px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">22px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#post1</span> a<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#post2</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;">#FFF</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#post1</span> a<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#post2</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">dotted</span> <span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#footerwidgettextfirst</span> p<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#footerwidgettextmiddle</span> p<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#footerwidgettextlast</span> p<span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#footertext</span> p <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Trebuchet MS&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">13px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/04-20_finished.jpg" width="549" height="1453" alt="Footer" /></div>
<h4>完成了！</h4>
<p>我希望你喜欢这部教程。请在下面提出你的问题和想法。</p>
<p><a class="more-link" href="http://demos.sixrevisions.com/2010/08/27/elegant-css3-weblayout.zip">下载源文件</a></p>
<h4>《简洁优雅的部落格网页布局教程》系列</h4>
<p>这篇教程是一个系列的第二集。这个部分(<strong>第二集</strong>)展示了如何利用第一集中建立的PSD设计制作一个HTML/CSS网页模板。</p>
<ul>
<li><strong>第一集：</strong><a href="http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/">使用Photoshop建立一个简洁优雅的部落格网页布局</a></li>
<li><strong>第二集：</strong><a href="http://sheneyan.com/blog/2010/10/psdhtml-conversion-elegant-and-simple-css3-web-layout/">PSD/HTML转换：简洁优雅的CSS3网页布局</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sheneyan.com/blog/2010/10/psdhtml-conversion-elegant-and-simple-css3-web-layout/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>使用Photoshop建立一个简洁优雅的部落格网页布局</title>
		<link>http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/</link>
		<comments>http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 02:00:05 +0000</pubDate>
		<dc:creator>子乌</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[翻译]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[布局]]></category>
		<category><![CDATA[教程]]></category>
		<category><![CDATA[网站设计]]></category>

		<guid isPermaLink="false">http://sheneyan.com/blog/?p=1420</guid>
		<description><![CDATA[<ul>
<li>作者： <a href="http://twitter.com/hatchergraphics" title="Eric Hoffman">Eric Hoffman</a></li>
<li>译者：<a href="http://sheneyan.com/blog">Sheneyan(子乌)</a></li>
<li>时间：2010-10-13</li>
<li>英文原文：<a href="http://sixrevisions.com/tutorials/photoshop-tutorials/make-an-elegant-and-simple-blog-web-layout-using-photoshop/">Make an Elegant and Simple Blog Web Layout Using Photoshop</a></li>
</ul>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-01_simple_elegant_photoshop_ld_img.jpg" width="550" height="250" alt="使用Photoshop建立一个简洁优雅的部落格网页布局" /></div>
<p><em>这篇网页设计教程会为你展示制作一个干净简单的部落格布局的PSD模板的过程。我们会制作这个部落格的首页设计。而教程的第二部分会引导你将PSD转换成HTML/CSS。</em></p>
<h4>《简洁优雅的部落格网页布局教程》系列</h4>
<p>这篇教程是一个系列的第一集。这部分(<strong>第一集</strong>)展示如何在Photoshop中制作模板，而在下一个教程(<strong>第二集</strong>)里你会看到如何利用这个PSD设计来制作HTML/CSS网页模板[......]</p><p class='read-more'><a href='http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<ul>
<li>作者： <a href="http://twitter.com/hatchergraphics" title="Eric Hoffman">Eric Hoffman</a></li>
<li>译者：<a href="http://sheneyan.com/blog">Sheneyan(子乌)</a></li>
<li>时间：2010-10-13</li>
<li>英文原文：<a href="http://sixrevisions.com/tutorials/photoshop-tutorials/make-an-elegant-and-simple-blog-web-layout-using-photoshop/">Make an Elegant and Simple Blog Web Layout Using Photoshop</a></li>
</ul>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-01_simple_elegant_photoshop_ld_img.jpg" width="550" height="250" alt="使用Photoshop建立一个简洁优雅的部落格网页布局" /></div>
<p><em>这篇网页设计教程会为你展示制作一个干净简单的部落格布局的PSD模板的过程。我们会制作这个部落格的首页设计。而教程的第二部分会引导你将PSD转换成HTML/CSS。</em></p>
<h4>《简洁优雅的部落格网页布局教程》系列</h4>
<p>这篇教程是一个系列的第一集。这部分(<strong>第一集</strong>)展示如何在Photoshop中制作模板，而在下一个教程(<strong>第二集</strong>)里你会看到如何利用这个PSD设计来制作HTML/CSS网页模板。</p>
<ul>
<li><strong>第一集：</strong><a href="http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/">使用Photoshop建立一个简洁优雅的部落格网页布局</a></li>
<li><strong>第二集：</strong><a href="http://sheneyan.com/blog/2010/10/psdhtml-conversion-elegant-and-simple-css3-web-layout/">PSD/HTML转换：简洁优雅的CSS3网页布局</a></li>
</ul>
<h4>最终成果</h4>
<p>点击下图可看到完整大小的工作成果。</p>
<p><a href="http://sheneyan.com/blog/wp-content/uploads/2010/10/final_result.jpg" rel="shadowbox[sbpost-1420];player=img;"></p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/final_result-657x1024.jpg" alt="" title="final_result" width="500" class="alignnone size-large wp-image-1421" /></div>
<p></a></p>
<h4>创建一个新的PSD文件</h4>
<p><span class="tutorial-number">1</span>让我们直接开始吧。首先，打开Adobe Photoshop(废话)。我使用的是CS4，但其他CS版本也能做得很好。先创建一个新文档(Ctrl/Cmd + N)；设置文档大小为<strong>1046</strong>&#215;<strong>1630</strong> px，<strong>白色</strong>背景。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-04_clean_elegant_webdesign.png" width="550" height="339" alt="创建一个新的PSD文件" /></div>
<h4>制作背景</h4>
<p><span class="tutorial-number">2</span>你的新PSD的背景图层应该是被锁定且无法编辑；我们需要为此做一些事。双击图层面板上的背景图层缩略图；会弹出一个新的图层对话窗口，点击OK按钮以使该图层可编辑。</p>
<p><span class="tutorial-number">3</span>现在按住Ctrl(或Cmd键)单击图层面板上的背景图层缩略图(默认情况下Photoshop会将其更名为Layer 0)以在画板周围放置一个选择框。</p>
<p><span class="tutorial-number">4</span>在工具面板中设置背景色为蓝色(<strong>#45a0ac</strong>)并使用快捷键Ctrl/Cmd+Backspace，让选中的部分填充上该背景色。</p>
<p><span class="tutorial-number">5</span>你的背景色现在应该已经设置为暗影蓝。确保背景图层仍被选中的情况下选择菜单<strong>滤镜 > 杂色 > 添加杂色</strong>。将数量改为2%并应用滤镜。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-05_clean_elegant_webdesign.jpg" width="550" height="290" alt="制作背景" /></div>
<h4>设置一些Photoshop初始参考线</h4>
<p><span class="tutorial-number">6</span> 为了方便我们的作品对齐，设置三条垂直参考线(视图 > 新参考线)在这几个位置：<strong>60.5px</strong>，<strong>505px</strong> 和 <strong>955px</strong>。</p>
<p><strong>技巧</strong>：使用快捷键Ctrl/Cmd + ; 来切换你的Photoshop参考线是否可见。</p>
<p><span class="tutorial-number">7</span>在<strong>40px</strong>处也设置一条水平参考线。</p>
<h4>添加部落格名称</h4>
<p><span class="tutorial-number">8</span>选择工具面板上的横排文字工具(T)，然后在左上角输入你的部落格名称。在这里，我使用字体<a href="http://www.fontsquirrel.com/fonts/Museo-Slab">Museo Slab 500</a>，字体大小65pt。字体颜色设置成了暗灰(<strong>#252525</strong>)，与我们暗蓝色的背景形成不错且有些微妙的对比。顺便说一下，当你选中横排文字工具后，你可以在选项栏中设置所有这些类型的选项。</p>
<p><span class="tutorial-number">9</span>在位于图层面板的你部落格名称的文本图层上双击鼠标，弹出图层样式对话框窗口。勾选投影和内投影样式以让文本有活版/插图排版效果。</p>
<p>修改投影的颜色为亮蓝(<strong>#3f9cb0</strong>)，混合模式为<strong>屏幕</strong>(<span class="notes">我猜是第一个“正常”，不过不是很确定</span>)，并把距离和大小设置为<strong>1px</strong>。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-06_clean_elegant_webdesign.png" width="550" height="453" alt="添加部落格名称" /></div>
<p>修改内投影的距离和大小为<strong>2px</strong>。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-07_clean_elegant_webdesign.png" width="550" height="444" alt="添加部落格名称" /></div>
<p><span class="tutorial-number">10</span>使用移动工具(V)将文本对齐到刚才设置的参考线以定位文本。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-08_clean_elegant_webdesign.jpg" width="550" height="127" alt="添加部落格名称" /></div>
<h4>添加主页导航菜单链接</h4>
<p><span class="tutorial-number">11</span>再次使用横排文字工具，使用和刚才相同的字体创建四个(独立的)导航栏链接，字体大小缩小为<strong>20pt</strong>。将他们写在不同的图层里。在这个教程中，菜单项分别为“Home”，“About”，“Archives”和“Contact”。</p>
<p><span class="tutorial-number">12</span>将第四个导航栏链接(“Contace”)对齐到参考线最右端，而第一个导航栏链接与部落格名称右侧的参考线对齐。其他两个链接在他们之间。</p>
<p><span class="tutorial-number">13</span>为了将他们对齐，在图层面板中选中这四个图层，然后选择<strong>图层 > 对齐 > 垂直</strong>。</p>
<p><span class="tutorial-number">14</span>为了保证导航栏链接之间有相同的空白，在图层面板上选中这四个图层，然后选择<strong>图层 > 分布 > 水平居中</strong>。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-09_clean_elegant_webdesign.jpg" width="550" height="78" alt="添加首页导航栏链接" /></div>
<p><span class="tutorial-number">15</span>在<strong>88px</strong>处添加一条水平参考线(视图 > 新参考线)，使用移动工具(V)将这些链接放置于参考线之上。</p>
<h4>制作活动导航菜单链接背景</h4>
<p><span class="tutorial-number">16</span>我们将用不同的背景色、字体颜色和阴影来高亮用户所在的页面。背景将会饰以类似“书签”的阴影(赋予我们布局一些视觉上的语义)。我会向你展示如何制作这个“书签”阴影。首先，创建一个新图层(将其命名为“linkbg”)。从工具面板中选中矩形选框工具(M)。在这个矩形选框工具的选项栏中，将样式选项改为<strong>固定大小</strong>并设置宽度选项为<strong>100px</strong>，高度选项为<strong>148px</strong>。将你的矩形选框置于画板上我们导航菜单栏周围。</p>
<p><span class="tutorial-number">17</span>改变背景色为我们的暗灰(<strong>#252525</strong>)，点击Ctrl/Cmd + Backspace 填充矩形阴影。</p>
<p><span class="tutorial-number">18</span>现在选中自定义形状工具(U)并在选项栏中设置形状选项为<strong>Arrow 2</strong>(是Photoshop于封装的自定义形状，<span class="notes">子乌注：不知道是不是我用的版本是简化版，没找到Arrow 2，我用Arrow 9代替</span>)。</p>
<p><span class="tutorial-number">19</span>使用自定义形状工具在你的画板上画这个箭头，然后在图层面板上选中它所在的图层，将其旋转以朝上 (<strong>编辑 > 变换 > 旋转90<sup>o</sup> 逆时针</strong>).</p>
<p><span class="tutorial-number">20</span>右键单击箭头图层，选择 栅格化图层 将其转换成普通图层。</p>
<p><span class="tutorial-number">21</span>在图层面板上修改图层的顺序以确保箭头图层在灰色“linkbg”层之上。</p>
<p><span class="tutorial-number">22</span>在图层面板上选中箭头图层和“linkbg”层，选择<strong>图层 > 对齐 > 水平居中</strong>。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-10_clean_elegant_webdesign.jpg" width="550" height="216" alt="制作活动导航菜单链接背景" /></div>
<p><span class="tutorial-number">23</span>Ctrl/Cmd + 单击图层面板的箭头图层缩略图以选中该图层，切换到“linkbg”图层，单击backspace或delete删除箭头图层下的区域。</p>
<p>做完之后，你不再需要这个箭头图层啦，干掉他就是了。</p>
<p><span class="tutorial-number">24</span>现在你的活动导航菜单连接已经有了一个看着像书签的背景。通过应用内发光、颜色叠加和描边来设计这个图层以匹配我们logo的观感。</p>
<p>内发光颜色设为暗灰 (<strong>#2e2d2d</strong>).</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-11_clean_elegant_webdesign.png" width="550" height="454" alt="制作活动导航菜单连接背景" /></div>
<p>颜色叠加再次使用我们的暗灰 (<strong>#252525</strong>)。你并不一定需要这个图层样式，因为之前我们已经使用了这个颜色填充图层。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-12_clean_elegant_webdesign.png" width="549" height="451" alt="制作活动导航菜单链接背景" /></div>
<p>描边颜色设为黑色 (<strong>#000000</strong>).</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-13_clean_elegant_webdesign.png" width="550" height="445" alt="制作活动导航菜单链接背景" /></div>
<p>现在我们的“书签”活动链接指示看起来应该像这样：</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-14_clean_elegant_webdesign.jpg" width="550" height="293" alt="制作活动导航菜单链接背景" /></div>
<h4>设定导航菜单链接的样式和位置</h4>
<p><span class="tutorial-number">25</span>现在该给我们的菜单栏链接设置一些样式。首先，添加一个投影样式到其他三个非激活连接上(“About”、“Archives”和“Contact”)。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-15_clean_elegant_webdesign.png" width="550" height="450" alt="设定导航菜单链接的样式和位置" /></div>
<p><span class="tutorial-number">26</span>下一步，使用横排文字工具(T)改变第一个链接(“Home”)的文本颜色为白色。</p>
<p><span class="tutorial-number">27</span>使用 <strong>图层 > 对齐 > 水平居中</strong>来水平对齐第一个链接和书签形状。我在“Home”文本下加了个在Adobe Illustrator下制作的小小的波浪矢量形状，不过可以不管它。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-16_clean_elegant_webdesign.jpg" width="550" height="179" alt="设定导航菜单链接的样式和位置" /></div>
<h4>制作水平内陷分隔线</h4>
<p><span class="tutorial-number">28</span>在<strong>160px</strong>处添加另一条水平参考线。</p>
<p><span class="tutorial-number">29</span>选中矩形选框工具(M)并创建一个 <strong>890&#215;1px</strong> 大小的瘦长选框。</p>
<p><span class="tutorial-number">30</span>添加新的图层(命名为“dividertop”)，在这个新图层上，单击Ctrl/Cmd+Backspace用任意颜色填充刚才的矩形。</p>
<p><span class="tutorial-number">31</span>给“dividertop”图层应用一个颜色叠加图层样式以使该矩形的颜色比我们的暗蓝背景颜色稍亮(<strong>#2c7c88</strong>)。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-17_clean_elegant_webdesign.png" width="550" height="452" alt="制作水平内陷分隔线" /></div>
<p><span class="tutorial-number">32</span>使用移动工具(V)将这个矩形与参考线左对齐和上对齐。</p>
<p><span class="tutorial-number">33</span>复制图层并将它向原有矩形的右下方移动。重命名图层为“dividerbottom”。</p>
<p><span class="tutorial-number">34</span>给它设置一个亮蓝颜色叠加图层样式(<strong>#4fbaca</strong>)。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-18_clean_elegant_webdesign.png" width="550" height="453" alt="制作水平内陷分隔线" /></div>
<p>在图层面板中同时选中“dividertop”和“dividerbottom”图层来链接它们——右键单击它们其中一个，从右键菜单中选择链接图层。这样当我们需要移动它们的时候它们会一起移动。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-19_clean_elegant_webdesign.png" width="550" height="88" alt="自作水平内陷分隔线" /></div>
<h4>设计发布日期背景</h4>
<p><span class="tutorial-number">35</span>我们现在完成了布局的头部区域。接下来是主体内容部分，先是第一个部落格文章条目的日期。再首先：我们需要在<strong>210px</strong>处添加另一条水平参考线。</p>
<p><span class="tutorial-number">36</span>在工具面板中选中圆角矩形工具(U)，在它的选项栏中，改变半径为<strong>10cm</strong>。</p>
<p><span class="tutorial-number">37</span>使用那个圆角矩形工具创建一个<strong>75&#215;150px</strong>大小的圆角矩形。</p>
<p><span class="tutorial-number">38</span>给刚才的圆角矩形图层应用一个内阴影样式——设置内阴影的颜色为蓝色(<strong>#3793a0</strong>)。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-20_clean_elegant_webdesign.png" width="550" height="457" alt="设计发布日期背景" /></div>
<p><span class="tutorial-number">39</span>应用一个比内阴影更深的蓝色叠加图层样式(<strong>#2c788</strong>).</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-21_clean_elegant_webdesign.png" width="550" height="451" alt="设计发布日期背景设计发布日期背景" /></div>
<p><span class="tutorial-number">40</span>给这个形状应用一个描边图层样式——使用比内阴影更深的蓝色线条颜色(<strong>#1a5a64</strong>)。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-22_clean_elegant_webdesign.png" width="550" height="455" alt="设计发布日期背景" /></div>
<p><span class="tutorial-number">41</span>将这个图层重名为“datebg”(意即“日期背景”)以使你的作品有组织，接着栅格化这个图层(右键单击，选择栅格化图层)。</p>
<p><span class="tutorial-number">42</span>使用矩形选框工具，选中形状右边部分的1/3，删除选中区域。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-23_clean_elegant_webdesign.jpg" width="550" height="210" alt="设计发布日期背景" /></div>
<p><span class="tutorial-number">43</span>还是在图层“datebg”，通过<strong>滤镜 > 杂色 > 添加杂色</strong>添加一个杂色滤镜，数量选项设置为<strong>2%</strong>。</p>
<h4>制作发布日期的垂直阴影</h4>
<p><span class="tutorial-number">44</span>现在给日期背景的阴影创建一个新图层。使用椭圆选框工具(M)，做一个大约<strong>17px</strong>宽<strong>100px</strong>高的椭圆形；最精确的方式是使用椭圆选框工具样式选项里的<strong>固定大小</strong>并输入宽和高的维度。</p>
<p><span class="tutorial-number">45</span>将这个选框置于日期背景的右端。使用黑色(<strong>#000000</strong>)填充选框(Shift+F5)并将图层命名为“shadow”。</p>
<p><span class="tutorial-number">46</span>在“shadow”图层上应用一个高斯模糊(滤镜 > 模糊 > 高斯模糊)，设定半径选项为<strong>3px</strong>。</p>
<p><span class="tutorial-number">47</span>使用矩形选框工具，选中该模糊椭圆阴影的右半部分，单击backspace或delete删除这半部分。</p>
<p><span class="tutorial-number">48</span>降低图层的透明度至<strong>55%</strong>，结束。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-24_clean_elegant_webdesign.jpg" width="550" height="181" alt="设计发布日期背景" /></div>
<h4>添加日期文本，文章标题，元数据</h4>
<p><span class="tutorial-number">49</span>日期背景完成后，接下来是添加部落格文章发布的日期。点击工具面板上的横排文字工具(T)，使用字体Museo Slab 500写下你的日期。数字天数的字体大小应该是<strong>42pt</strong>，而月份——位于数字天数下的一行——为<strong>20pt</strong>。我输入的是“13 APR”，APR另起一行。</p>
<p><span class="tutorial-number">50</span>使用移动工具和之前使用过的图层对齐命令对齐半椭圆阴影(图层“shadow”)、日期背景(“datebg”)和日期文本图层。</p>
<p><span class="tutorial-number">51</span>至于文章的标题，我选择Georgia系列字体，<strong>35pt</strong>大小。而元数据(作者、回复数)，我使用<strong>20pt</strong>的Trajan Pro。你可以看到我用<a href="http://www.ascii.cl/htmlcodes.htm">middle dot/Georgian comma</a>来分隔作者名与回复数——直接复制并将其黏贴到Photoshop中。另外，修改文本行高为<strong>28px</strong>。你可以在<strong>窗口 > 字符</strong>面板中修改。</p>
<p>下面是我们的日期，部落格文章标题，以及文章元数据。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-25_clean_elegant_webdesign.jpg" width="550" height="150" alt="添加日期文本，文章标题，元数据" /></div>
<p><span class="tutorial-number">52</span>在<strong>165px</strong>处添加一条垂直参考线。将你的文本与参考线和日期对齐。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-26_clean_elegant_webdesign.jpg" width="550" height="156" alt="添加日期文本，文章标题，元数据" /></div>
<h4>添加部落格文章前置图像</h4>
<p><span class="tutorial-number">53</span>使用矩形选框工具(M)，创建一个<strong>480&#215;150px </strong>矩形(高取决于你使用的图像尺寸，但针对这个模板，最大宽度为480px)。</p>
<p><span class="tutorial-number">54</span>在一个新图层上使用随便一种颜色填充你的选框，然后应用一个描边图层样式来给我们的图片加个边框。边框的颜色是暗灰(<strong>#1b1b1b</strong>)。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-27_clean_elegant_webdesign.png" width="550" height="454" alt="添加部落格文章前置图像" /></div>
<h4>添加并定位部落格文章内容</h4>
<p><span class="tutorial-number">55</span>照一张你的图片并将其黏贴到你的PSD文件中。我用了一张滑雪板的图，不过你选什么样的图片并不重要；它只是我们PSD样板中的小点缀(eye candy，华而不实的东西)。使用自由变换(Ctrl/Cmd + T)调整你图片的大小以使其恰好塞进我们的矩形框中。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-28_clean_elegant_webdesign.jpg" width="550" height="225" alt="添加并定位部落格文章内容" /></div>
<p><span class="tutorial-number">56</span>切换到横排文字工具(T)并在图片下黏贴一些文本。你可以使用类似<a href="http://www.lipsum/">这个</a>的Loerm Ipsum生成工具(<span class="notes">用于排版的常用无意义文字</span>)在一瞬间生成些文本，不过用一些网页副本来让这个样板尽可能的真实不会是个坏主意。我为文本内容选用的字体是<a href="http://www.discusgroup.co.uk/trebuchet.htm">Trebuchet MS</a>，<strong>17pt</strong>大小，并设置行高为<strong>28pt</strong>。</p>
<p><span class="tutorial-number">57</span>在图层面板中选中所有的部落格文章设计元素并以我们创建的参考线为基准对齐。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-29_clean_elegant_webdesign.jpg" width="550" height="102" alt="添加并定位部落格文章内容" /></div>
<p><span class="tutorial-number">58</span>在<strong>450px</strong>处添加一条新的水平参考线。让文本与左侧参考线和新参考线对齐。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-30_clean_elegant_webdesign.jpg" width="550" height="475" alt="添加并定位部落格文章内容" /></div>
<p><span class="tutorial-number">59</span>从图层面板中选中所有的部落格文章图层(“datebg”、“shadow”、“date”、部落格文章标题文本、元数据文本、图片背景、图片以及部落格文章文本)，试用 图层编组(Ctrl/Cmd + G)将他们一起分组，这会让所有的所有这些图层位于同一个文件夹下。命名这个图层分组为“Post 1”。</p>
<h4>在部落格文章底部加一条内陷水平分割线</h4>
<p><span class="tutorial-number">60</span>在<strong>700px</strong>处添加另一条水平参考线。复制我们刚才创建的分割线并命名该图层为“dividerpost”。</p>
<p><span class="tutorial-number">61</span>使用自由变换调整这个分割线的尺寸让它和前置图像一样宽度。接着使用移动工具(V)将其挪动到我们刚创建的水平参考线位置。</p>
<h4>添加另一篇部落格文章</h4>
<p><span class="tutorial-number">62</span>复制图层分组“Post 1”并重命名为“Post 2”。</p>
<p><span class="tutorial-number">63</span>在<strong>720px</strong>处添加新的水平参考线，将Post 2的日期框的阴影与新参考线对齐。</p>
<p><span class="tutorial-number">64</span>改变图层分组“Post 2”的元素以使它与第一篇部落格文章区分开来；比如，改掉回复数，日期，和部落格文章标题。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-31_clean_elegant_webdesign.jpg" width="550" height="589" alt="添加另一篇部落格文章" /></div>
<h4>制作侧边栏背景</h4>
<p><span class="tutorial-number">65</span>使用矩形选框工具创建一个<strong>250&#215;350px</strong>大小的矩形(在一个新图层将这个矩形选框用随便一种颜色填充，并将新矩形命名为“sidebar”)。这个矩形是我们的侧边栏背景。</p>
<p><span class="tutorial-number">66</span>让这个侧边栏与位于<strong>210px</strong>的水平参考线和我们之前创建的最右边的垂直参考线对齐。</p>
<p><span class="tutorial-number">67</span>给这个侧边栏背景设一个颜色叠加图层样式；颜色叠加的颜色设为暗蓝(<strong>#2c7c88</strong>)。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-32_clean_elegant_webdesign.png" width="550" height="450" alt="制作侧边栏背景" /></div>
<p><span class="tutorial-number">68</span>另外，给侧边栏背景也设一个描边图层样式，描边颜色更暗一些(<strong>#116678</strong>)。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-33_clean_elegant_webdesign.png" width="550" height="443" alt="制作侧边栏背景" /></div>
<p><span class="tutorial-number">69</span>在<strong>730px</strong>和<strong>930px</strong>各设置一条垂直参考线；我们利用这些参考线确保在我们的侧边栏内部有一些留白。</p>
<h4>制作搜索栏</h4>
<p><span class="tutorial-number">70</span>使用圆角矩形工具(U)从左边的垂直参考线(730px位置)画至右边的垂直参考线；这个圆角矩形大约<strong>25px</strong>高。将这个阴影图层命名为“searchbar”。给这个圆角矩形设一个白色(<strong>#ffffff</strong>)的颜色叠加图层样式。</p>
<p><span class="tutorial-number">71</span>找一个放大镜图标来充当搜索按钮(你可以使用类似<a href="http://www.iconfinder.com/">IconFinder</a>的在线工具来寻找免费图标)。</p>
<p><span class="tutorial-number">72</span>将这个图标定位在白色圆角矩形内部(在其左部)。</p>
<p><span class="tutorial-number">73</span>创建一条就像我们之前做的水平分割线。跨度从730px的垂直参考线到930px的垂直参考线。在它和搜索栏之间保留一点小小的空白。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-34_clean_elegant_webdesign.jpg" width="549" height="141" alt="制作搜索栏" /></div>
<h4>添加侧边栏文字</h4>
<p><span class="tutorial-number">74</span>现在轮到文字了。我使用横排文字工具(T)加了一个侧边栏标题(“最近文章”)——Georia字体，字体大小<strong>23pt</strong>。其下我列了最近发布的三篇部落格文章，使用字体Trebuchet MS，大小<strong>17pt</strong>，行高<strong>28pt</strong>。将这个文本图层命名为“recent posts”。</p>
<p><span class="tutorial-number">75</span>复制上面的水平分割线并将它移动到“recent posts”的底部。</p>
<p><span class="tutorial-number">76</span>创建另一个类似的文本图层，命名为“recent comments”。</p>
<p><span class="tutorial-number">77</span>将这两个文本块与左侧参考线对齐。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-35_clean_elegant_webdesign.jpg" width="550" height="356" alt="添加侧边栏文字" /></div>
<h4>设计侧边栏广告位</h4>
<p><span class="tutorial-number">78</span>使用矩形选框工具画一对<strong>118&#215;118px</strong>大小的正方形。按住shift键以确保你的方块的宽和高完全一致。</p>
<p><span class="tutorial-number">79</span>将一个方块右对齐(靠向右边参考线)而另一个左对齐(靠向左边参考线)。</p>
<p><span class="tutorial-number">80</span>使用灰色(<strong>#f6f6f6</strong>)颜色涂层叠加样式填充这两个正方形。这是给我们的部落格放置 <a href="http://sixrevisions.com/design-showcase-inspiration/banner-ads-examples/" title="Banner Ads: Excellent Examples for Inspiration - sixrevisions.com">banner广告</a>的地方。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-36_clean_elegant_webdesign.png" width="550" height="411" alt="设计侧边栏广告位" /></div>
<p><span class="tutorial-number">81</span>将这两个灰色方块复制两次或更多，这取决于你打算放几个广告。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-37_clean_elegant_webdesign.jpg" width="550" height="451" alt="设计侧边栏广告位" /></div>
<h4>侧边栏整理</h4>
<p><span class="tutorial-number">82</span>将所有的侧边栏元素图层编组并命名这个图层分组为“sidebar”以保持我们的样板整洁(如果你和一个将你的PSD转成HTML/CSS的前端工程师一起工作，他会因此爱死你的)。</p>
<h4>布局主体页脚</h4>
<p><span class="tutorial-number">83</span>新增两条新的水平参考线：一条在<strong>1220px</strong>而另一条位于<strong>1550px</strong>。</p>
<p><span class="tutorial-number">84</span>使用矩形选框工具(M)，横跨整个页面布局宽度——两条新参考线之间——画一个矩形，这就是我们的页脚呆的地方。使用暗灰(<strong>#2c7c88</strong>填充矩形。这是我们的页脚背景。</p>
<p><span class="tutorial-number">85</span>给我们的页脚背景应用一个杂色滤镜(滤镜 > 杂色 > 添加杂色)，数量设为<strong>1%</strong>。</p>
<p><span class="tutorial-number">86</span>给页脚背景应用一个黑色(<strong>#000000</strong>)内阴影图层样式。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-38_clean_elegant_webdesign.png" width="550" height="455" alt="布局主体页脚" /></div>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-39_clean_elegant_webdesign.jpg" width="550" height="340" alt="布局主体页脚" /></div>
<p><span class="tutorial-number">87</span>现在添加三个一样尺寸的文本栏，全都一样宽度。在这里，我为页脚文本的真实网页副本而从维基百科复制了一些有趣的内容。标题(“Widget title”)设为Georiga，<strong>23pt</strong>，普通文本则为Trebuchet MS，<strong>17pt</strong>。别忘了将行高改为<strong>28pt</strong>！</p>
<h4>制作主体页脚栏目分割线</h4>
<p><span class="tutorial-number">88</span>为了制作页脚文本栏目之间的白色垂直分割线，我们将使用图案(pattern)。第一部是创建一个新的PSD文件(Ctrl/Cmd + N)，宽度为<strong>1px</strong>、高度为<strong>3px</strong>。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-40_clean_elegant_webdesign.png" width="550" height="343" alt="制作主体页脚栏目分割线" /></div>
<p><span class="tutorial-number">89</span>放大到足够近以让你能看清你的作品(使用缩放工具)。</p>
<p><span class="tutorial-number">90</span>使用矩形选框工具和<strong>编辑 > 填充</strong>将第一个像素(顶端)染为黑色(<strong>#000000</strong>)。</p>
<p><span class="tutorial-number">91</span>选中整个画板(Ctrl/Cmd + A)然后选择 编辑 > 定义图案(<span class="notes">子乌注：CS4中将Define Pattern翻译为定义图案</span>)。命名你的模式，如“Vertical Dots”。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-41_clean_elegant_webdesign.png" width="550" height="169" alt="制作主体页脚栏目分割线" /></div>
<p><span class="tutorial-number">92</span>切换回我们的主要Photoshop文档。</p>
<p><span class="tutorial-number">93</span>创建垂直的矩形选框(<strong>1&#215;280px</strong>)。</p>
<p><span class="tutorial-number">94</span>添加新的图层并单击Shift + F5查看填充对话框窗口。在<strong>使用</strong>选项下拉菜单中，从列表中找到我们刚创建的图案(“Vertical Dots”)并单击OK，使用它来将我们的矩形选框填满。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-42_clean_elegant_webdesign.jpg" width="550" height="256" alt="制作主体页脚栏目分割线" /></div>
<p><span class="tutorial-number">95</span>复制这个虚线垂直分割线图层并将它们放置于三个页脚栏目之间。</p>
<p><span class="tutorial-number">96</span>将这些文本栏目进行编组，垂直对齐。</p>
<p><span class="tutorial-number">97</span>添加一个白色颜色叠加图层样式到每一个虚线垂直分割线上，让他们显示为白色。</p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/11-43_clean_elegant_webdesign.jpg" width="550" height="336" alt="制作主体页脚栏目分割线" /></div>
<h4>创建辅助页脚</h4>
<p><span class="tutorial-number">98</span>就在布局的正底部创建一个短的矩形选框，并用暗灰(<strong>#1f2024</strong>)填充。</p>
<p><span class="tutorial-number">99</span>应用杂色滤镜，数量设为<strong>1%</strong>。</p>
<p><span class="tutorial-number">100</span>输入一些文本，例如你的版权信息，使用字体Trebuchet MS，<strong>17pt</strong>。将文本与最左边的参考线水平对齐。</p>
<h4>结束！</h4>
<p>大功告成！这不是很简单吗？(<span class="notes">照着做很简单……我翻这100条翻了好久……</span>)</p>
<p><a href="http://sheneyan.com/blog/wp-content/uploads/2010/10/final_result.jpg" rel="shadowbox[sbpost-1420];player=img;"></p>
<div><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/final_result-657x1024.jpg" alt="" title="final_result" width="500" class="alignnone size-large wp-image-1421" /></div>
<p></a></p>
<h4>简洁优雅的部落格网页布局教程系列</h4>
<ul>
<li><strong>第一集：</strong><a href="http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/">使用Photoshop建立一个简洁优雅的部落格网页布局</a></li>
<li><strong>第二集：</strong><a href="http://sheneyan.com/blog/2010/10/psdhtml-conversion-elegant-and-simple-css3-web-layout/">PSD/HTML转换：简洁优雅的CSS3网页布局</a></li>
</ul>
<h4>下载源文件</h4>
<ul>
<li><a href='http://sheneyan.com/blog/wp-content/uploads/2010/10/simple_elegant_bloglayout-psd.zip'>psd文件</a> (ZIP, 1.61 MB)</li>
</ul>
<p class="notes">子乌注：以后我都会用部落格来翻译blog，还是喜欢这个台湾的译法。</p>
]]></content:encoded>
			<wfw:commentRss>http://sheneyan.com/blog/2010/10/make-an-elegant-and-simple-blog-web-layout-using-photoshop/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>简单实用的wp插件:ozh-random-words</title>
		<link>http://sheneyan.com/blog/2010/10/simple-and-useful-wp-plugin-ozh-random-words/</link>
		<comments>http://sheneyan.com/blog/2010/10/simple-and-useful-wp-plugin-ozh-random-words/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 14:08:41 +0000</pubDate>
		<dc:creator>子乌</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress插件]]></category>

		<guid isPermaLink="false">http://sheneyan.com/blog/?p=1363</guid>
		<description><![CDATA[<p><a href="http://planetozh.com/blog/my-projects/wordpress-plugin-random-words/">ozh-random-words</a>是一个很简单但是很实用的wordpress插件，它的功能很简单，就是随机输出设定好的一系列html字符串。而用途就大了，比如可以随机更换banner，随机更换广告，随机更换与访客的问候语，随机更换皮肤……<br />
例如，我想随机更换我“华丽的分割线”，我只需要在ozh-random-words的配置后台配置一系列的分割线图片html（假设这组html叫做split，具体的配置方法参见作者的说明，就上面那个链接），我只要在我的post中写下（[]之间没空格！）:</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&#160;&#160;HTML</div>[ random:split ]</div></div>

<p>然后刷新页面就会看到输[......]</p><p class='read-more'><a href='http://sheneyan.com/blog/2010/10/simple-and-useful-wp-plugin-ozh-random-words/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://planetozh.com/blog/my-projects/wordpress-plugin-random-words/">ozh-random-words</a>是一个很简单但是很实用的wordpress插件，它的功能很简单，就是随机输出设定好的一系列html字符串。而用途就大了，比如可以随机更换banner，随机更换广告，随机更换与访客的问候语，随机更换皮肤……<br />
例如，我想随机更换我“华丽的分割线”，我只需要在ozh-random-words的配置后台配置一系列的分割线图片html（假设这组html叫做split，具体的配置方法参见作者的说明，就上面那个链接），我只要在我的post中写下（[]之间没空格！）:</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;">[ random:split ]</pre></div></div>

<p>然后刷新页面就会看到输出一个随机的分割线来(如下图，每次刷新都会变)：</p>
<p><img alt="华丽的分割线" title="华丽的分割线" src="http://sheneyan.com/image/line/line_149.gif" /></p>
<p>不过这样一来就会有一个问题，假如随机输出内容很多，那每次加载页面时速度会很慢；或者说当你不希望每次刷新时都改变输出内容（而只想一天改一次），那你可以试着像我这样对插件进行修改（这个插件上次更新是一两年前，看作者的意思除非不兼容最新版本的wordpress他就不会再更新了，所以就放心大胆地改吧~），修改ozh-random-words/wp_ozh_randomwords.php文件，增加如下函数：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;PHP</div><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//这个函数的作用是一天生成一个缓存文件然后直接读取缓存内容，</span>
<span style="color: #666666; font-style: italic;">//这样会大大减少对超长字符串的处理。</span>
<span style="color: #009933; font-style: italic;">/**added by Sheneyan 2010.10.09**/</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_ozh_randomwords_perday<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$display</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//取得当前路径</span>
	<span style="color: #000088;">$self_path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//如果入参为空,直接返回空字符串</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//取得缓存文件名(当前路径/入参名_当前日期)</span>
	<span style="color: #000088;">$today_cache_file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$self_path</span><span style="color: #339933;">.</span><span style="color: #000088;">$input</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Ymd'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//如果缓存文件不存在（不能够从文件中读出数据）</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$today_cache_file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//调用原有函数取得随机字符串</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> wp_ozh_randomwords<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//将随机字符串存入缓存文件中</span>
		<span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$today_cache_file</span><span style="color: #339933;">,</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//昨天的缓存文件名</span>
	<span style="color: #000088;">$fn</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$self_path</span><span style="color: #339933;">.</span><span style="color: #000088;">$input</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Ymd'</span><span style="color: #339933;">,</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-1 day'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//如果昨天的缓存文件还存在，则删除（忽略错误）</span>
<span style="color: #666666; font-style: italic;">//如果担心删除文件影响性能，可以放在cron中执行或者</span>
<span style="color: #666666; font-style: italic;">//放到wordpress的定时执行中执行。</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fn</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">@</span><span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//如果需要立刻显示则打印到屏幕，否则返回。</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$display</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">print</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>这样修改完后可以在模板中直接这样调用：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;PHP</div><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?=</span>wp_ozh_randomwords_perday<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'split'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>不过如果想在post直接实用shortcode调用的话，还需要进一步修改插件源码。先增加如下函数：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;PHP</div><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> wp_ozh_randomwords_returnword_perday<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//直接调用刚才写的函数，记得设定不立刻显示</span>
	<span style="color: #b1b100;">return</span> wp_ozh_randomwords_perday<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>找到函数<code>wp_ozh_randomwords_postcontent</code>，做如下修改（在patch_start和patch_end之间的代码是新增的）：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;PHP</div><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> wp_ozh_randomwords_postcontent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">/* replace [random:animals] inside posts */</span>
	<span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace_callback</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\[random:([^\]]+)\]/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wp_ozh_randomwords_returnword&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/**added by Sheneyan 2010.10.09**/</span>
<span style="color: #009933; font-style: italic;">/**patch_start*/</span>
<span style="color: #666666; font-style: italic;">//过滤shortcode randompd</span>
	<span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace_callback</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\[randompd:([^\]]+)\]/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wp_ozh_randomwords_returnword_perday&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/**patch_end*/</span>
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>经过修改，我们增加了一个新的shortcode <code>randompd</code>，只要这样调用即可（记得去掉[]前后空格）：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;">[ randompd:split ]</pre></div></div>

<p><img alt="华丽的分割线" title="华丽的分割线" src="http://sheneyan.com/image/line/line_147.gif" /></p>
<p>如何？效果出来了吧？我页面上的Daily English也是调用这个插件生成的。</p>
<p>这个插件很简单，甚至可以说有些简陋，但是这样留给我们的运用空间就相当的大了，怎么用，就看你的了</p>
]]></content:encoded>
			<wfw:commentRss>http://sheneyan.com/blog/2010/10/simple-and-useful-wp-plugin-ozh-random-words/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>给wp-syntax插件增加标题</title>
		<link>http://sheneyan.com/blog/2010/10/enchance-wp-syntax/</link>
		<comments>http://sheneyan.com/blog/2010/10/enchance-wp-syntax/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 12:22:50 +0000</pubDate>
		<dc:creator>子乌</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress插件]]></category>
		<category><![CDATA[wp-syntax]]></category>

		<guid isPermaLink="false">http://sheneyan.com/blog/?p=1284</guid>
		<description><![CDATA[<p><a href="http://wordpress.org/extend/plugins/wp-syntax/">wp-syntax</a>估计是每个技术类blog都会使用的代码高亮插件（你没用？嗯……当我没说），不过却有一个小小的缺陷：没有提供标题，而这个功能在插件内使用的<a href="http://qbnz.com/highlighter/index.php">GeSHi</a>中是可以设定的，下面就简单说一下如何修改源码，让你的高亮源码块的标题头显示出高亮代码的所属语言。</p>
<p>我对源码做了三个修改：</p>
<ol>
<li>增加显示当前语言的标题栏（有兴趣的童鞋可以加上复制代码、收缩代码、打印啥的……）</li>
<li>将原来的行数标记的实现改变（原来的实现是只有当设定<code>line="1"</code>时才显示行数），当没有设定行数或者设定行数为1的时候，显示行数，当行数设置为0的时候才不显示行，这样省得我在每个代码块中加上参数<code>line="1"</code>&#8230;</li>
<li>修正[......]</li></ol><p class='read-more'><a href='http://sheneyan.com/blog/2010/10/enchance-wp-syntax/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://wordpress.org/extend/plugins/wp-syntax/">wp-syntax</a>估计是每个技术类blog都会使用的代码高亮插件（你没用？嗯……当我没说），不过却有一个小小的缺陷：没有提供标题，而这个功能在插件内使用的<a href="http://qbnz.com/highlighter/index.php">GeSHi</a>中是可以设定的，下面就简单说一下如何修改源码，让你的高亮源码块的标题头显示出高亮代码的所属语言。</p>
<p>我对源码做了三个修改：</p>
<ol>
<li>增加显示当前语言的标题栏（有兴趣的童鞋可以加上复制代码、收缩代码、打印啥的……）</li>
<li>将原来的行数标记的实现改变（原来的实现是只有当设定<code>line="1"</code>时才显示行数），当没有设定行数或者设定行数为1的时候，显示行数，当行数设置为0的时候才不显示行，这样省得我在每个代码块中加上参数<code>line="1"</code>&#8230;</li>
<li>修正了显示行数时代码不宽显示的小问题。</li>
</ol>
<h4>增加标题栏</h4>
<p>在wordpress控制台找到编辑插件的地方，编辑wp-syntax的文件<code>wp-syntax.php</code>(喜欢在直接修改源文件的就去<code>/wp-content/plugins/wp-syntax/</code>目录下找吧)，找到下列代码：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;PHP</div><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//显示行数</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;table&gt;&lt;tr&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>line_numbers<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> wp_syntax_line_numbers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span><span style="color: #339933;">,</span> <span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parse_code</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//不显示行数</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;div class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parse_code</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>稍微修改一下：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;PHP</div><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;table&gt;&lt;tr&gt;&lt;td colspan='2' class='code_header'&gt;Language:&amp;nbsp;&amp;nbsp;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_language_name</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>line_numbers<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> wp_syntax_line_numbers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span><span style="color: #339933;">,</span> <span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parse_code</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;div class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;div class='code_header'&gt;Language:&amp;nbsp;&amp;nbsp;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_language_name</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parse_code</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>然后找到<code>wp-syntax.css</code>文件，在最后面增加一行：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;">.code_header<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span><span style="color: #993333;">solid</span> <span style="color: #933;">1px</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>一个很简单但我觉得还算实用的标题头就出现了（因为wp-syntax将代码的高亮展示部分完全自行实现，所以没法直接使用GeSHi的方法<code>set_header_content</code>）。</p>
<h4>默认显示行数</h4>
<p>那个啥，我觉得默认显示行数的话会更实用，因为显示行数的话看起来比较专业 <img src='http://sheneyan.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>还是刚才的<code>wp-syntax.php</code>，就在我们刚才修改的第一句：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;PHP</div><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #339933;">...</span>
<span style="color: #339933;">...</span>
<span style="color: #339933;">...</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>修改为:</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;PHP</div><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$line</span><span style="color: #339933;">||</span><span style="color: #000088;">$line</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;1&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #339933;">...</span>
<span style="color: #339933;">...</span>
<span style="color: #339933;">...</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>这样就搞定了~~下面的代码分别是设定是否显示行数的示例，看看：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">pre</span> <span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;html4strict&quot;</span> escaped<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>这个代码块我默认没提供line参数，不过依然会显示行数<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">pre</span>&gt;</span></pre></div></div>


<div class="wp_syntax"><table><tr><td colspan='2' class='code_header'>Language:&nbsp;&nbsp;HTML</td></tr><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">pre</span> <span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;html4strict&quot;</span> escaped<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> line<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>这个代码块我设定了line=&quot;1&quot;，会显示行数<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">pre</span>&gt;</span></pre></td></tr></table></div>


<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;HTML</div><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">pre</span> <span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;html4strict&quot;</span> escaped<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> line<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>这个代码块我设定line=&quot;0&quot;，不会显示行数，
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>需要注意的是：只要是&quot;非0&quot;的值我就不显示行数！<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>，
想显示行数的话就将前面的$line==&quot;1&quot;改成$line!=&quot;0&quot;即可。<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">pre</span>&gt;</span></pre></div></div>

<p>关于上面三个demo，我有两点需要说明一下：</p>
<ol>
<li>html的lang是<strong>html4strict</strong>而不是<strong>html或htm</strong>，注意一下，否则无法高亮，标题也会显示“unknown language”，觉得不爽的童鞋可以修改一下GeSHi的声明……</li>
<li>上面的代码块我都使用了参数<code>escaped="true"</code>，这样可以让&lt;/pre>正常显示，不过需要写成<strong>&amp;lt;/pre></strong>，而且bt的wordpress的编辑器会自动帮助你把<strong>&amp;lt;</strong>修改成<strong>&lt;</strong>，写代码时要注意一下……</li>
</ol>
<h4>带行数时显示问题</h4>
<p>如果像我一样一直都没设置过line参数的话，估计都不会发现wp-syntax的这个小小bug，当代码不够宽的时候，他无法将代码内容占满整行，下面是错误图例：</p>
<p><a href="http://sheneyan.com/blog/wp-content/uploads/2010/10/wp_syntax_error.jpg" rel="lightbox[1284]" rel="shadowbox[sbpost-1284];player=img;" title="wp_syntax_error"><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/wp_syntax_error-300x73.jpg" alt="" title="wp_syntax_error" width="300" height="73" class="alignnone size-medium wp-image-1299" /></a></p>
<p>修改的方式很简单（只在chrome 6.0.472.63/ie 8/firefox 3.6.2下测试通过……不过估计只要是常规的浏览器应该没太大问题，这不涉及css hack吧 <img src='http://sheneyan.com/blog/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' /> ），找到刚才修改过的文件<code>wp-syntax.css</code>的如下代码：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.wp_syntax</span> table <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">border-collapse</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">collapse</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>修改为：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;CSS</div><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.wp_syntax</span> table <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">border-collapse</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">collapse</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">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: #00AA00;">&#125;</span></pre></div></div>

<p>好了，应该无问题了~</p>
<h4>补充说明</h4>
<p>wp-syntax的现有代码相当简洁，很好理解，如果够闲，还可以给它写一套dashboard下使用的配置界面以控制其显示的效果 <img src='http://sheneyan.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ……</p>
]]></content:encoded>
			<wfw:commentRss>http://sheneyan.com/blog/2010/10/enchance-wp-syntax/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>两张壁纸</title>
		<link>http://sheneyan.com/blog/2010/10/2-wallpapers/</link>
		<comments>http://sheneyan.com/blog/2010/10/2-wallpapers/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 01:20:40 +0000</pubDate>
		<dc:creator>子乌</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[日记]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[壁纸]]></category>

		<guid isPermaLink="false">http://sheneyan.com/blog/?p=1269</guid>
		<description><![CDATA[<p>第一张是基本linux命令的壁纸，扔桌面上，碰到想不起什么命令的时候看看桌面即可-_-(via <a href="http://tuxtraining.com/2008/10/02/handy-wallpaper-for-basic-linux-commands">tuxtraining.com</a>)</p>
<p><a href="http://sheneyan.com/blog/wp-content/uploads/2010/10/client_cmd.png" rel="lightbox[1269]" rel="shadowbox[sbpost-1269];player=img;" title="handy wallpaper for basic linux commands"><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/client_cmd-300x240.png" alt="" title="handy wallpaper for basic linux commands" width="300" height="240" class="alignnone size-medium wp-image-1270" /></a></p>
<p>第二张是vim的常用命令（via <a href="http://w.riku.me/_detail/4422771876_2a7b233e47_o.png?id=Home">riku</a>）</p>
<p><a href="http://sheneyan.com/blog/wp-content/uploads/2010/10/vim-keybinding.png" rel="lightbox[1269]" rel="shadowbox[sbpost-1269];player=img;" title="vim-keybinding"><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/vim-keybinding-300x211.png" alt="" title="vim-keybinding" width="300" height="211" class="alignnone size-medium wp-image-1271" /></a></p>]]></description>
			<content:encoded><![CDATA[<p>第一张是基本linux命令的壁纸，扔桌面上，碰到想不起什么命令的时候看看桌面即可-_-(via <a href="http://tuxtraining.com/2008/10/02/handy-wallpaper-for-basic-linux-commands">tuxtraining.com</a>)</p>
<p><a href="http://sheneyan.com/blog/wp-content/uploads/2010/10/client_cmd.png" rel="lightbox[1269]" rel="shadowbox[sbpost-1269];player=img;" title="handy wallpaper for basic linux commands"><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/client_cmd-300x240.png" alt="" title="handy wallpaper for basic linux commands" width="300" height="240" class="alignnone size-medium wp-image-1270" /></a></p>
<p>第二张是vim的常用命令（via <a href="http://w.riku.me/_detail/4422771876_2a7b233e47_o.png?id=Home">riku</a>）</p>
<p><a href="http://sheneyan.com/blog/wp-content/uploads/2010/10/vim-keybinding.png" rel="lightbox[1269]" rel="shadowbox[sbpost-1269];player=img;" title="vim-keybinding"><img src="http://sheneyan.com/blog/wp-content/uploads/2010/10/vim-keybinding-300x211.png" alt="" title="vim-keybinding" width="300" height="211" class="alignnone size-medium wp-image-1271" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sheneyan.com/blog/2010/10/2-wallpapers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>招聘经理希望程序员拥有的5个素质</title>
		<link>http://sheneyan.com/blog/2010/10/qualities-every-hiring-manager-wants-in-a-developer/</link>
		<comments>http://sheneyan.com/blog/2010/10/qualities-every-hiring-manager-wants-in-a-developer/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 05:33:56 +0000</pubDate>
		<dc:creator>子乌</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[翻译]]></category>
		<category><![CDATA[招聘]]></category>
		<category><![CDATA[程序员]]></category>
		<category><![CDATA[素质]]></category>

		<guid isPermaLink="false">http://sheneyan.com/blog/?p=1267</guid>
		<description><![CDATA[<ul>
<li>译者：<a href="http://sheneyan.com/blog">Sheneyan(子乌)</a></li>
<li>时间：2010-10-07</li>
<li>英文原文：<a href="http://education.internet.com/articles/5-qualities-every-hiring-manager-wants-in-a-developer/">5 Qualities Every Hiring Manager Wants in a Developer</a></li>
</ul>
<p>当提及程序员的工作技能或必备素质的时候，在互联网上会看到充斥着各种各样的列表。而涉及到程序员的工作说明时，很多人并不具备那些相同的品质，怎么办？</p>
<h4>招聘理念影响程序员的必备素质</h4>
<p>从某种程度上讲，这取决于公司的招聘理念及认为哪个更有价值：开发技能还是其他无形的品质。Rob Mallery在洛杉矶的<a href="http://www.originatelabs.com/">Originate Labs, Inc.</a>（<span class="notes"><a href="http://www.originatechina.com/index.html">中文站</a></span>）任企业发展经理(Director of Corporate Develop[......]</p><p class='read-more'><a href='http://sheneyan.com/blog/2010/10/qualities-every-hiring-manager-wants-in-a-developer/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<ul>
<li>译者：<a href="http://sheneyan.com/blog">Sheneyan(子乌)</a></li>
<li>时间：2010-10-07</li>
<li>英文原文：<a href="http://education.internet.com/articles/5-qualities-every-hiring-manager-wants-in-a-developer/">5 Qualities Every Hiring Manager Wants in a Developer</a></li>
</ul>
<p>当提及程序员的工作技能或必备素质的时候，在互联网上会看到充斥着各种各样的列表。而涉及到程序员的工作说明时，很多人并不具备那些相同的品质，怎么办？</p>
<h4>招聘理念影响程序员的必备素质</h4>
<p>从某种程度上讲，这取决于公司的招聘理念及认为哪个更有价值：开发技能还是其他无形的品质。Rob Mallery在洛杉矶的<a href="http://www.originatelabs.com/">Originate Labs, Inc.</a>（<span class="notes"><a href="http://www.originatechina.com/index.html">中文站</a></span>）任企业发展经理(Director of Corporate Development)。Originate Labs是一家创投资源公司，其雇员是该领域中最优秀的。“我们与创业公司合作并投资我们的工程技术人才以换取股权或现金/股票。所以我们的工程师们必须达到或超过创业公司会雇佣的第一个或第二个‘建设工程师’这种类型人员的水平。所以我们的标注与那些大而‘稳’的公司不同”，Mallery解释道，“我宁可要那些拥有所有我们所期望的素质而完全没有我们所期望技能的任”。</p>
<p>在行业里许多招工启示中所缺少的是素质——而非开发技能或IT证书——负责招聘程序员的人们都同意这点。虽然名称不尽相同，这个列表将各种列表和说明的元素归纳为五个素质——每个人事经理希望程序员拥有的。</p>
<h4>1、智力</h4>
<p>虽然在招工启示中很少出现“更聪明”这样的字眼，但这是一个程序员工作必备的。Mark Herschberg是ZepFrog的CEO以及麻省理工学院(MIT)兼职讲师，在他的职业生涯中进行过很多次的招聘。实际上，他用了10个礼拜时间创建了一个20人的部门并招聘了许多来自创业公司或大企业如NBC和Sears的程序员。Herschberg解释说：“聪明的人会好的多。你可以教他们技能或知识但你没法教给他们智慧。”</p>
<p>Mallery同意这一点。“我们的工程师中前百分之一到百分之二的人与其他人最大的不同在于他们可以利用其高超的智慧来攻克问题而其他人则要用百分之九十的时间来纠正自己的错误。仅有的一些坏苹果会脱慢一个团队的效率因为所有人都需要为他们写的坏代码。”</p>
<h4>2、把事情做好（GTD——Get Things Done）</h4>
<p>Joel Spolsky，Fog Creek Software的创始人，有一个在技术产业被经常引用的两段式招聘理念：“聪明，而且能把事情做好”。他在文章（<a href="http://www.joelonsoftware.com/articles/GuerrillaInterviewing3.html">The Guerrilla Guide to Interviewing (version 3.0)</a>）中如是说。Spolsky阐释了为什么只有聪明还是不够。“那些聪明但没法<strong>把事情做好</strong>的人经常是有博士学位且在没有人会听他的大公司工作，因为他们完全不切实际。”一些人称之为“自我驱动”或“内部动机”，但落实到开发工作上则需要产生结果。</p>
<h4>3、算法和分析技能</h4>
<p>一个求职者<strong>能够思考</strong>并不够，还需要他懂<strong>如何思考</strong>。大多数招工启示称之为“过硬的分析技能”。Herschberg将其更进一步，寻找不同的思维模式，因为求职者所熟悉的其他类型的思维，不止是抽象层或面向对象原则，可以增加团队的维度。</p>
<h4>4、沟通技巧</h4>
<p>Puramu，拥有五年技术管理经验的Arizona的社交媒体经理，在IT.Toolbox.com上指出一些程序员“自傲于不善沟通”并认为他们的代码能独立运行且完全不需要进行解释。Puramu简单地评论：“这很傻”。</p>
<p>Herschberg说：“软件开发更多的是一个社会学挑战而不是简单的技术挑战。成员之间交流的顺畅以共享思路与问题是非常重要的。他们至少要能够与其他工程师进行交流；最理想的是能够与非工程师交流。”</p>
<h4>5、正确的个人理念</h4>
<p>正确的个人理念每个公司都不相同，但都包括了以团队为重心的态度，胜利的姿态，谦逊以及好奇心。Herschberg描述了他所寻找的：“不止是一个积极的态度，还要如某人所说，‘我会找到一个方法来获得成功。’”</p>
<p>同样，Mallery的观点也是类似的。“缺乏自我是构造一个成功的由优秀工程师组成的团队的重要部分。这往往可以在那些敏捷或其他基于合作的环境下工作良好的工程师身上发现。他们并不考虑关于‘自己’的事情，而是考虑‘我们’的事情，而且他们会努力让最终结果变得更好，即便他们没有获得全部的荣誉。”</p>
]]></content:encoded>
			<wfw:commentRss>http://sheneyan.com/blog/2010/10/qualities-every-hiring-manager-wants-in-a-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>11个最常用的MySQL语句</title>
		<link>http://sheneyan.com/blog/2010/10/11-most-common-mysql-queries/</link>
		<comments>http://sheneyan.com/blog/2010/10/11-most-common-mysql-queries/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 02:02:39 +0000</pubDate>
		<dc:creator>子乌</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[翻译]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[教程]]></category>

		<guid isPermaLink="false">http://sheneyan.com/blog/?p=1265</guid>
		<description><![CDATA[<ul>
<li>作者： <a href="http://www.databasejournal.com/feedback.php/http://www.databasejournal.com/features/mysql/article.php/3904531" title="Sachin Khosla">Sachin Khosla</a></li>
<li>译者：<a href="http://sheneyan.com/blog">Sheneyan(子乌)</a></li>
<li>时间：2010-10-06</li>
<li>英文原文：<a href="http://www.databasejournal.com/features/mysql/article.php/3904531/article.htm">The 10 Most Common MySQL Queries</a></li>
</ul>
<p class="notes">子乌注：嗯，纯入门的mysql教程。</p>
<h4>1、创建表</h4>
<p>在正常情况下估计没几个人会每次都使用脚本创建表(<span class="notes">嗯，深得我心……</span>)。不过，当你开始创建一个应用的时候，你需要创建数据库表。你可以使用下列语句来创建一个带主键的表。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&#160;&#160;MySQL</div><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span>  <span style="color: #008000;">'emp'</span> <span style="color: #FF00FF;">&#40;</span>
  <span style="color: #008000;">'id'</span> <span style="color: #999900; font-weight: bold;">INTEGER</span> <span style="color: #FF9900; font-weight: bold;">UNSIGNED</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #000033;">,</span>
  <span style="color: #008000;">'[......]</span></div></div><p class='read-more'><a href='http://sheneyan.com/blog/2010/10/11-most-common-mysql-queries/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<ul>
<li>作者： <a href="http://www.databasejournal.com/feedback.php/http://www.databasejournal.com/features/mysql/article.php/3904531" title="Sachin Khosla">Sachin Khosla</a></li>
<li>译者：<a href="http://sheneyan.com/blog">Sheneyan(子乌)</a></li>
<li>时间：2010-10-06</li>
<li>英文原文：<a href="http://www.databasejournal.com/features/mysql/article.php/3904531/article.htm">The 10 Most Common MySQL Queries</a></li>
</ul>
<p class="notes">子乌注：嗯，纯入门的mysql教程。</p>
<h4>1、创建表</h4>
<p>在正常情况下估计没几个人会每次都使用脚本创建表(<span class="notes">嗯，深得我心……</span>)。不过，当你开始创建一个应用的时候，你需要创建数据库表。你可以使用下列语句来创建一个带主键的表。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span>  <span style="color: #008000;">'emp'</span> <span style="color: #FF00FF;">&#40;</span>
  <span style="color: #008000;">'id'</span> <span style="color: #999900; font-weight: bold;">INTEGER</span> <span style="color: #FF9900; font-weight: bold;">UNSIGNED</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #000033;">,</span>
  <span style="color: #008000;">'name'</span> <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">45</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
  <span style="color: #008000;">'lastname'</span> <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">45</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
  <span style="color: #008000;">'dept'</span> <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">45</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">DEFAULT</span> <span style="color: #008000;">'sales'</span><span style="color: #000033;">,</span>
  <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'id'</span><span style="color: #FF00FF;">&#41;</span>
<span style="color: #FF00FF;">&#41;</span>
<span style="color: #990099; font-weight: bold;">ENGINE</span> <span style="color: #CC0099;">=</span> <span style="color: #990099; font-weight: bold;">InnoDB</span><span style="color: #000033;">;</span></pre></div></div>

<p>上述语句在指定数据库中创建了一个名为“emp”的表。同时会有一个有主键约束的自增长字段“id”，自增保证了每次插入新行的时候id都会加1，而主键约束则用来检验重复值。字段“dept”被赋予了默认值（当没设定内容时为“sales”）。你可以在创建表的时候指定“引擎”。否则会使用默认引擎（MyISAM）。我们在这里使用“InnoDB”是因为它支持<strong>外键</strong>和事务处理。</p>
<h4>2、 插入语句</h4>
<p>现在你的数据库里有了一张表，我们接下来看看如何在表里插数据。你可能已经使用插入语句很多次了，不过你用过既可以插入也可以更新（需要的话）的语句吗？这可以使用关键字“on DUPLICATE KEY”实现。下面是个例子：</p>
<h5>简单的插入语句</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">insert</span> <span style="color: #990099; font-weight: bold;">into</span> emp <span style="color: #FF00FF;">&#40;</span>name<span style="color: #000033;">,</span>lastname<span style="color: #000033;">,</span>dept<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">values</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'new name'</span><span style="color: #000033;">,</span><span style="color: #008000;">'new last name'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Accounts'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<h5>插入/更新语句</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">insert</span> <span style="color: #990099; font-weight: bold;">into</span> emp <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>lastname<span style="color: #000033;">,</span>dept<span style="color: #FF00FF;">&#41;</span> 
<span style="color: #990099; font-weight: bold;">values</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'key that already exists'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'new name'</span><span style="color: #000033;">,</span><span style="color: #008000;">'new last name'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Accounts'</span><span style="color: #FF00FF;">&#41;</span>
<span style="color: #990099; font-weight: bold;">on</span> <span style="color: #990099; font-weight: bold;">duplicate KEY</span> <span style="color: #990099; font-weight: bold;">UPDATE</span>  name<span style="color: #CC0099;">=</span><span style="color: #008000;">'default name'</span><span style="color: #000033;">,</span> lastname<span style="color: #CC0099;">=</span><span style="color: #008000;">'default last name'</span><span style="color: #000033;">;</span></pre></div></div>

<p>在上面的查询语句中，如果传递给“id”的值已经存在，我们可以更新该行的内容而不是插入新行。当你需要检验字段而不是直接插入自增值时这会相当有用。</p>
<h4>3、 连接</h4>
<p>因为连接有太多类型而显得很复杂。在不同的数据库中连接拥有不同的名称：自连接（self join），外连接（outer join），内连接（inner join），自然连接（natural join）等等。我们通常在两张表之间使用连接以获取数据。</p>
<p>让我们假设我们有另一张叫做“departments”的表，在其中存放了所有部门的数据。如果你想要获取带部门信息的雇员信息，查询语句应该是长这样子：</p>
<h5>常规连接（Regular join<span class="notes">子乌注：这并不是连接的一种定义，只是来与左连接和右连接区分而已</span>）</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">select</span> emp.name<span style="color: #000033;">,</span>department.name <span style="color: #990099; font-weight: bold;">from</span> emp 
<span style="color: #990099; font-weight: bold;">join</span> department <span style="color: #990099; font-weight: bold;">on</span> emp.dept <span style="color: #CC0099;">=</span> department.name</pre></div></div>

<h5>左连接（Left join）</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">select</span> emp.name<span style="color: #000033;">,</span>department.name <span style="color: #990099; font-weight: bold;">from</span> emp 
<span style="color: #000099;">left</span> <span style="color: #990099; font-weight: bold;">join</span> department <span style="color: #990099; font-weight: bold;">on</span> emp.dept <span style="color: #CC0099;">=</span> department.name</pre></div></div>

<h5>右连接（Right join）</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">select</span> emp.name<span style="color: #000033;">,</span>department.name <span style="color: #990099; font-weight: bold;">from</span> emp 
<span style="color: #000099;">right</span> <span style="color: #990099; font-weight: bold;">join</span> department <span style="color: #990099; font-weight: bold;">on</span> emp.dept <span style="color: #CC0099;">=</span> department.name</pre></div></div>

<p>常规连接会取得两张表中满足条件的全部数据。左连接会匹配符合条件的记录，不过它也会返回左表中不符合条件的数据。另一方面，右连接会取得右表中所有不符合条件的数据。（<span class="notes">子乌注：话说我还是喜欢oracle中外联的简化写法(+)，多好看啊</span>）</p>
<h4>4、 创建和删除约束</h4>
<p>如果你经常需要编辑/创建/删除表的约束，你可以这么写：</p>
<h5>添加主键</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #008000;">'TABLE<span style="color: #008080; font-weight: bold;">_</span>NAME'</span>  
<span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">ADD</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'COLUMN<span style="color: #008080; font-weight: bold;">_</span>NAME'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<h5>删除主键</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #008000;">'TABLE<span style="color: #008080; font-weight: bold;">_</span>NAME'</span>  <span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span><span style="color: #000033;">;</span></pre></div></div>

<p>在添加主键的时候，我们需要先删除已经添加的主键然后将新主键加到新字段上。否则将不允许加主键。</p>
<h4>5、 Order by，having子句</h4>
<p>Order by用于将数据按照指定字段重新整理，而<code>having</code>则用于过滤结果集。当你需要从一个大数据库中获取特定信息时这会非常有用：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">Select</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">from</span> TABLE_NAME 
<span style="color: #990099; font-weight: bold;">group by</span> dept  <span style="color: #990099; font-weight: bold;">having</span> salary <span style="color: #CC0099;">&gt;</span> <span style="color: #008080;">10000</span><span style="color: #000033;">;</span></pre></div></div>

<p>上述查询语句中会返回根据部门进行组织且工资大于10000的员工数据。值得注意的是当我们使用没有“order by”的“having”子句时，它更像“where”子句(<span class="notes">子乌注：对于oracle用户来说（我忘记sqlserver是不是也是这样了……）需要注意的地方是，mysql的group by可以不用将字段列明！而且结果也不太一样！确实更像where一些</span>)。</p>
<h4>6、 添加索引和搜索查询</h4>
<p>为一个字段创建索引毫无疑问会减少（<span class="notes">原文是increase……</span>）对数据库的查询，而索引是基于字段基础创建。例如，在我们的示例表“emp”，如果我们大部分获取数据的查询都是使用字段id，那为字段id建一个索引会是个明智的决定。</p>
<p>查询时，MySQL首先在已建立的索引中搜索ID，如果找不到则会在表级上运行查询。所以，正确地建立索引将提高这个过程的速度。</p>
<p>为了创建索引，可以使用以下语句：</p>
<h5>建表时创建索引</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span>  <span style="color: #008000;">'emp'</span> <span style="color: #FF00FF;">&#40;</span>
Name <span style="color: #999900; font-weight: bold;">varchar</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">45</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
  <span style="color: #008000;">'id'</span> <span style="color: #999900; font-weight: bold;">INT</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">INDEX</span><span style="color: #FF00FF;">&#40;</span>ID<span style="color: #FF00FF;">&#41;</span>
<span style="color: #FF00FF;">&#41;</span></pre></div></div>

<p class="notes">子乌注：如果已经是主键则无须创建索引。</p>
<h5>为已存在的表创建索引</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">Create</span> <span style="color: #990099; font-weight: bold;">Index</span> id_index <span style="color: #990099; font-weight: bold;">on</span> emp<span style="color: #FF00FF;">&#40;</span>ID<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<h4>7、 复合函数查询</h4>
<p>复合函数用于对从数据库取得的数据进行数学运算。这些函数包括：<code>sum</code>(<span class="notes">总和</span>)、<code>count</code>(<span class="notes">总数</span>)等。例如，如果你想计算工作于特定部门的雇员数，你可以这么写：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">select</span> <span style="color: #990099; font-weight: bold;">distinct</span> name<span style="color: #000033;">,</span><span style="color: #000099;">count</span><span style="color: #FF00FF;">&#40;</span>dept<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">as</span> cnt <span style="color: #990099; font-weight: bold;">from</span> emp
 <span style="color: #990099; font-weight: bold;">group by</span> dept  <span style="color: #990099; font-weight: bold;">order by</span> cnt <span style="color: #990099; font-weight: bold;">DESC</span><span style="color: #000033;">;</span></pre></div></div>

<p>上述语句会返回员工姓名及部门数，并会根据返回的总数对数据进行逆序组合。(<span class="notes">子乌注：对oracle用户来说（呃……我主要用oracle工作），order by的参数得是count(dept)而非cnt</span>)</p>
<h4>8、 变更及修改表字段</h4>
<p>表创建后可能会频繁修改。通过下面的语句我们可以看到如何给一个已存在的表添加/修改字段。</p>
<h5>添加字段</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">Alter</span> <span style="color: #990099; font-weight: bold;">table</span> <span style="color: #008000;">'emp'</span> <span style="color: #990099; font-weight: bold;">add</span> <span style="color: #990099; font-weight: bold;">column</span> salary <span style="color: #999900; font-weight: bold;">varchar</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">45</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<h5>修改字段</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">Alter</span> <span style="color: #990099; font-weight: bold;">table</span> <span style="color: #008000;">'emp'</span> <span style="color: #990099; font-weight: bold;">modify</span> <span style="color: #990099; font-weight: bold;">column</span> salary <span style="color: #999900; font-weight: bold;">int</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">10</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<h5>重命名字段</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">Alter</span> <span style="color: #990099; font-weight: bold;">table</span> <span style="color: #008000;">'emp'</span> change salary salary2 <span style="color: #999900; font-weight: bold;">varchar</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">45</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<h5>删除字段</h5>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">Alter</span> <span style="color: #990099; font-weight: bold;">table</span> <span style="color: #008000;">'emp'</span> <span style="color: #990099; font-weight: bold;">drop</span> <span style="color: #990099; font-weight: bold;">column</span> salary<span style="color: #000033;">;</span></pre></div></div>

<p class="notes">子乌注：对oracle用户来说（我又来了……），尽量不要随意修改表结构，否则与该表相关的所有对象（存储、触发器、索引、函数等等）全部会失效，需要重新编译。</p>
<h4>9、 使用非重复值创建新表</h4>
<p>假设你的数据库表中已经有了上千的数据，而你发现数据录入并不正确，存在着重复记录。现在你打算清理所有的垃圾并创建一个新表。让我们看看该如何做吧：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">create</span> <span style="color: #990099; font-weight: bold;">table</span> <span style="color: #008000;">'emp2'</span> <span style="color: #990099; font-weight: bold;">as</span> <span style="color: #990099; font-weight: bold;">select</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">from</span> emp
 <span style="color: #990099; font-weight: bold;">where</span> <span style="color: #008080;">1</span> <span style="color: #990099; font-weight: bold;">group by</span> <span style="color: #008000;">'lastname'</span><span style="color: #000033;">;</span></pre></div></div>

<p>嗯，现在创建了一个只有唯一“last name”的雇员信息的新表“emp2”。你可以使用不同的接口来排序你的表。</p>
<h4>10、 复制数据库并优化表</h4>
<p>很多时候你的应用需要进行计划备份并通过邮件发送或将其存放在安全的地方。你可以写个脚本执行并设置一个cron来做这事情。这会节省大量用于备份你的数据的工作并避免发生无可挽回的错误。让我们看看你该如何创建数据库的备份并同时优化表。</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;Bash</div><pre class="bash" style="font-family:monospace;">mysqldump –h localhost –u username –ppassword databasename <span style="color: #000000; font-weight: bold;">&gt;</span> backup_file.sql</pre></div></div>

<p>这会创建一个<dfn>sql dump</dfn>文件，可以将其再次导入以恢复数据库。</p>
<h4>11、 优化表</h4>
<p>在MySQL中优化表相当的简单，就像标题所说的那样：</p>

<div class="wp_syntax"><div class="code"><div class='code_header'>Language:&nbsp;&nbsp;MySQL</div><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">Optimize</span> <span style="color: #990099; font-weight: bold;">table</span> TABLE_NAME</pre></div></div>

<h4>结论</h4>
<p>你已经学会了这些在每天编码中都会用到的最常用的MySQL语句。你可以针对自己的工作场景来改进他们。</p>
]]></content:encoded>
			<wfw:commentRss>http://sheneyan.com/blog/2010/10/11-most-common-mysql-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

