<?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://blog.iworm.net/category/%e8%ae%be%e8%ae%a1/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.iworm.net</link>
	<description>争取不惑之年成为一名自由摄影师</description>
	<lastBuildDate>Tue, 07 Sep 2010 05:36:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>为何1024*768分辨率下网页的宽度为960px</title>
		<link>http://blog.iworm.net/2009/02/24/%e4%b8%ba%e4%bd%951024768%e5%88%86%e8%be%a8%e7%8e%87%e4%b8%8b%e7%bd%91%e9%a1%b5%e7%9a%84%e5%ae%bd%e5%ba%a6%e4%b8%ba960px/</link>
		<comments>http://blog.iworm.net/2009/02/24/%e4%b8%ba%e4%bd%951024768%e5%88%86%e8%be%a8%e7%8e%87%e4%b8%8b%e7%bd%91%e9%a1%b5%e7%9a%84%e5%ae%bd%e5%ba%a6%e4%b8%ba960px/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 15:04:08 +0000</pubDate>
		<dc:creator>iworm</dc:creator>
				<category><![CDATA[设计]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.iworm.net/?p=572</guid>
		<description><![CDATA[昨天在学习用 {zh:栅格设计&#124;栅格系统} 进行网页排版。 里面提到了适合1024宽度屏幕时，一般采用960px作为网页的宽度。 请到网页栅格系统研究（1）：960的秘密看原因。 我下面这段程序就是为了证明为什么960是比较合适的。 Python语言: 为何1024*768分辨率下网页的宽度为960px #!/usr/bin/python # -*- coding: utf-8 -*- #此代码证明使用栅格系统设计网页时, 为何1024分辨率最佳网页宽度是960px MaxWidth = 1024 group = {} #总宽度 for width in range(2, MaxWidth): &#160;&#160;&#160; count = 0 &#160;&#160;&#160; #栅格宽度 &#160;&#160;&#160; for gridWidth in range(2, MaxWidth): &#160;&#160;&#160;&#160;&#160;&#160;&#160; #如果可以有整数个栅格 &#160;&#160;&#160;&#160;&#160;&#160;&#160; if width % gridWidth == 0: &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; count = count + 1 [...]]]></description>
			<content:encoded><![CDATA[<p>昨天在学习用 {zh:栅格设计|栅格系统} 进行网页排版。<br />
里面提到了适合1024宽度屏幕时，一般采用960px作为网页的宽度。<br />
请到<a href="http://ued.taobao.com/blog/2008/10/22/grid_system_research_1/">网页栅格系统研究（1）：960的秘密</a>看原因。<br />
我下面这段程序就是为了证明为什么960是比较合适的。</p>
<div style="background: rgb(253, 253, 253) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><u>Python语言</u>: <a href="http://www.fayaa.com/code/view/670/">为何1024*768分辨率下网页的宽度为960px</a></div>
<div style="font-family: &quot;[object HTMLOptionElement]&quot;,&quot;Consolas&quot;,&quot;Lucida Console&quot;,&quot;Courier New&quot;; background-color: rgb(249, 247, 237);" class="source"> <span style="color: rgb(0, 136, 0); font-style: italic;">#!/usr/bin/python</span><br /> <span style="color: rgb(0, 136, 0); font-style: italic;"># -*- coding: utf-8 -*-</span></p>
<p> <span style="color: rgb(0, 136, 0); font-style: italic;">#此代码证明使用栅格系统设计网页时, 为何1024分辨率最佳网页宽度是960px</span><br /> MaxWidth = <span style="color: rgb(0, 0, 255);">1024</span><br /> group = {}<br /> <span style="color: rgb(0, 136, 0); font-style: italic;">#总宽度</span><br /> <span style="color: rgb(0, 0, 128); font-weight: bold;">for</span> width <span style="font-weight: bold;">in</span> range(<span style="color: rgb(0, 0, 255);">2</span>, MaxWidth):<br /> &nbsp;&nbsp;&nbsp; count = <span style="color: rgb(0, 0, 255);">0</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">#栅格宽度</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">for</span> gridWidth <span style="font-weight: bold;">in</span> range(<span style="color: rgb(0, 0, 255);">2</span>, MaxWidth):<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">#如果可以有整数个栅格</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> width % gridWidth == <span style="color: rgb(0, 0, 255);">0</span>:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count = count + <span style="color: rgb(0, 0, 255);">1</span></p>
<p> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> group.has_key(count):<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; group[count] = group[count] + <span style="color: rgb(0, 0, 255);">&#39;, &#39;</span> + str(width);<br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">else</span>:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; group[count] = str(width);</p>
<p> <span style="color: rgb(0, 0, 128); font-weight: bold;">print</span> group<br /> <span style="color: rgb(0, 136, 0); font-style: italic;">#通过结果可知</span><br /> <span style="color: rgb(0, 136, 0); font-style: italic;">#网页宽度为1008时, 最多可以设计含有29个纵向栅格的系统. 但是1008和1024之间只差了16px, 考虑到滚动条宽度 + 浏览器边框肯定大于16px, 所以不能使用1008px.</span><br /> <span style="color: rgb(0, 136, 0); font-style: italic;">#使用960px最多可以设计含有27个纵向栅格的系统.</span><br /> <span style="color: rgb(0, 136, 0); font-style: italic;">#使用990px最多可以设计含有23个纵向栅格的系统.</span></div>
<p>根据程序的运行结果以及我的一点简单分析，可以知道960px是很合适的。为什么不用990px宽呢？因为它仅仅比960px宽了30px，也就是几个字的宽度，但是减少了4个有效的栅格（也就是每个栅格的宽度变宽了，所以用的栅格少了），这可能会给某些情况下的排版会带来一定的问题。</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.iworm.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.iworm.net/2009/02/24/%e4%b8%ba%e4%bd%951024768%e5%88%86%e8%be%a8%e7%8e%87%e4%b8%8b%e7%bd%91%e9%a1%b5%e7%9a%84%e5%ae%bd%e5%ba%a6%e4%b8%ba960px/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
