<?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>Hiro技术站 &#187; CSS</title>
	<atom:link href="http://www.ihiro.org/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ihiro.org</link>
	<description></description>
	<lastBuildDate>Fri, 06 Jan 2012 07:58:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>CSS:区分IE版本的三个方法</title>
		<link>http://www.ihiro.org/css-specific-for-internet-explorer</link>
		<comments>http://www.ihiro.org/css-specific-for-internet-explorer#comments</comments>
		<pubDate>Wed, 02 Mar 2011 02:59:37 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[CSS、XHTML]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[技巧]]></category>
		<category><![CDATA[译文]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=1612</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2011/03/ie-specific-css.png" alt="" title="ie-specific-css" width="100" height="100" class="alignleft size-full wp-image-1616" />
<p>虽然我们从心理上都不愿意去处理IE的bug，但我们不得不面对老板和浏览者们仍然在使用IE。介于不同浏览器有不同的渲染器，这往往会使开发者们感到很沮丧。我们通常使用IE条件判断语言来处理IE的CSS问题，但其实还是有其他的一些方法来处理IE的CSS bug的。</p>
<p>一、IE条件判断语句； 二、CSS规则（IE CSS hacks）； 三、HTML条件判断，给出不同的className。</p>
<p>本文翻译自：<a href="http://www.webdesignerwall.com/tutorials/css-specific-for-internet-explorer/" rel="external">CSS Specific for Internet Explorer</a></p>]]></description>
			<content:encoded><![CDATA[<p>虽然我们从心理上都不愿意去处理IE的bug，但我们不得不面对老板和浏览者们仍然在使用IE。介于不同浏览器有不同的渲染器，这往往会使开发者们感到很沮丧。我们通常使用IE条件判断语言来处理IE的CSS问题，但其实还是有其他的一些方法来处理IE的CSS bug的。</p>
<h3>一、IE条件判断语句</h3>
<p>IE条件判断语句也许是用的最多的区分IE版本(IE6, IE7, IE8)的办法了。看看下面用来区分IE不同版本的代码：</p>
<ul>
<li>* <code>&lt;!--[if IE 8]&gt;</code> = IE8版本</li>
<li>* <code>&lt;!--[if lt IE 8]&gt;</code> = IE7版本以低版本</li>
<li>* <code>&lt;!--[if gte IE 8]&gt;</code> = IE8版本及高版本</li>
</ul>
<p>
<div class="wp_codebox"><table><tr id="p16121"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p1612code1"><pre class="html" style="font-family:monospace;">&lt;!--[if IE 8]&gt;
&lt;style type=&quot;text/css&quot;&gt;
	/* css for IE 8 */
&lt;/style&gt;
&lt; ![endif]--&gt;
&nbsp;
&lt;!--[if lt IE 8]&gt;
	&lt;link href=&quot;ie7.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt; ![endif]--&gt;</pre></td></tr></table></div>

</p>
<h3>二、CSS规则（IE CSS hacks）</h3>
<p>另一个办法就是在样式文件中声明只有IE识别的CSS规则。比如，在CSS属性前置一个”*”区分IE7和低版本，而前置一个”_”则区分IE6及低版本。但是，很多时候这个方法不被推荐，因为这些CSS规则并不能被W3C CSS 验证成功。</p>
<ul>
<li>* IE8 及 低版本: 在CSS属性后置”\9&#8243;, 如 <code>height:1000px\9;</code></li>
<li>* IE7 及 低版本: 在CSS属性前置”*”, 如 <code>*height:1000px;</code></li>
<li>* IE6 及 低版本: 在CSS属性前置”_”, 如 <code>_height:1000px;</code></li>
</ul>
<p>
<div class="wp_codebox"><table><tr id="p16122"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p1612code2"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.box</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;">gray</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* standard */</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> pink\<span style="color: #cc66cc;">9</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* IE 8 and below */</span>
&nbsp;
	<span style="color: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">green</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* IE 7 and below */</span>
&nbsp;
	_background<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* IE 6 */</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<h3>三、HTML条件判断，给出不同的className</h3>
<p>第三个办法是由<a href="http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/" rel="external">Paul Irish</a>发起的。它实现的办法是通过IE条件判断来给HTML设置不同的className，然后在CSS中通过给不同的className下的后代设置不同的样式即可实现。这个办法比较可行，也不会有任何W3C验证的问题。</p>
<p>
<div class="wp_codebox"><table><tr id="p16123"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p1612code3"><pre class="html" style="font-family:monospace;">&lt;!--[if lt IE 7 ]&gt; &lt;html class=&quot;ie6&quot;&gt; &lt; ![endif]--&gt;
&lt;!--[if IE 7 ]&gt; &lt;/html&gt;&lt;html class=&quot;ie7&quot;&gt; &lt; ![endif]--&gt;
&lt;!--[if IE 8 ]&gt; &lt;/html&gt;&lt;html class=&quot;ie8&quot;&gt; &lt; ![endif]--&gt;
&lt;!--[if IE 9 ]&gt; &lt;/html&gt;&lt;html class=&quot;ie9&quot;&gt; &lt; ![endif]--&gt;
&lt;!--[if (gt IE 9)|!(IE)]&gt;&lt;!--&gt; &lt;/html&gt;&lt;html&gt; &lt;!--&lt;![endif]--&gt;
&lt;/html&gt;</pre></td></tr></table></div>

</p>
<p>本文翻译自：<a href="http://www.webdesignerwall.com/tutorials/css-specific-for-internet-explorer/" rel="external">CSS Specific for Internet Explorer</a></p>
<p class="green">PS:这三种办法我个人都用过，只是第三中办法我不是给HTML便签设置不同的className,而是在BODY中所有HTML代码的最外层多嵌套了一层DIV。呵呵，想想，还是给HTML或BODY标签设置不同className比较合算。至少不会有多余的标签。</p>
<h3>扩展阅读：</h3>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx" rel="external">About Conditional Comments</a></li>
</ul>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2010年05月17日 -- <a href="http://www.ihiro.org/target-every-version-of-ie-from-a-single-stylesheet" title="CSS:通过一个样式表区分IE的各个版本">CSS:通过一个样式表区分IE的各个版本</a> (11)</li><li>2010年03月8日 -- <a href="http://www.ihiro.org/css3-basic" title="CSS:CSS3基础（附图）">CSS:CSS3基础（附图）</a> (12)</li><li>2009年09月3日 -- <a href="http://www.ihiro.org/share-some-common-techniques-of-css" title="CSS:分享一些常用的css技巧">CSS:分享一些常用的css技巧</a> (8)</li><li>2010年11月25日 -- <a href="http://www.ihiro.org/css-position-hack" title="CSS:position属性定位总结">CSS:position属性定位总结</a> (27)</li><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2010年06月12日 -- <a href="http://www.ihiro.org/firefox-4-will-support-css3-calc-method" title="CSS:Firefox 4 将支持CSS3 calc方法">CSS:Firefox 4 将支持CSS3 calc方法</a> (18)</li><li>2010年03月15日 -- <a href="http://www.ihiro.org/uncovering-jquerys-hidden-features" title="jQuery:揭露jQuery的隐藏功能">jQuery:揭露jQuery的隐藏功能</a> (5)</li><li>2010年02月20日 -- <a href="http://www.ihiro.org/how-to-insert-googlebuzz-data-into-blog" title="Wordpress:如何将GoogleBuzz数据插入到博客中">Wordpress:如何将GoogleBuzz数据插入到博客中</a> (11)</li><li>2010年01月22日 -- <a href="http://www.ihiro.org/jquery-1-4-released-the-15-new-features-you-should-know-2" title="jQuery:1.4新版本中你应该知道的15个新特性(二)">jQuery:1.4新版本中你应该知道的15个新特性(二)</a> (7)</li><li>2010年01月20日 -- <a href="http://www.ihiro.org/jquery-1-4-released-the-15-new-features-you-should-know-1" title="jQuery:1.4新版本中你应该知道的15个新特性(一)">jQuery:1.4新版本中你应该知道的15个新特性(一)</a> (6)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/css-specific-for-internet-explorer/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>CSS:position属性定位总结</title>
		<link>http://www.ihiro.org/css-position-hack</link>
		<comments>http://www.ihiro.org/css-position-hack#comments</comments>
		<pubDate>Thu, 25 Nov 2010 03:37:42 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[CSS、XHTML]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[前端工程]]></category>
		<category><![CDATA[总结笔记]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=1568</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/11/position-logo.jpg" alt="" title="position-logo" width="100" height="100" class="alignleft size-full wp-image-1571" />
<p>在写这篇文章之前，我一直以为css中position定位时一直是读取最后出现两个方位属性的值。昨天给一同事演示jQuery的animate特效时，我试图通过js来控制已经设置过top和left的DIV的right属性为0，以达到滑动到最右边的效果。结果没有效果，很是郁闷。</p>
<p>早上写了一些关于postion的样式做测试，发现不论给某个DIV设置了多少个方位（当然最多到4个），也不管存放的顺序是如何颠倒，它的读取顺序依旧是top-bottom-left-right.很符合日常所说的“上下左右”规则。这与我之前理解的不相符合。</p>]]></description>
			<content:encoded><![CDATA[<p>在写这篇文章之前，我一直以为css中position定位时一直是读取最后出现两个方位属性的值。昨天给一同事演示jQuery的animate特效时，我试图通过js来控制已经设置过top和left的DIV的right属性为0，以达到滑动到最右边的效果。结果没有效果，很是郁闷。</p>
<p>早上写了一些关于postion的样式做测试，发现不论给某个DIV设置了多少个方位（当然最多到4个），也不管存放的顺序是如何颠倒，它的读取顺序依旧是top-bottom-left-right.很符合日常所说的“上下左右”规则。这与我之前理解的不相符合。</p>
<p>另外我们也知道给一个标签设置magin、padding、border等时，它的顺序是“上右下左”，这个顺序和方位读取顺序也没有类似的关系。为此我总结了一份Demo页面，供大家对比方位读取顺序，也算是一个总结笔记吧。</p>
<p class="demo-down-bar"><a target="_blank" href="http://www.ihiro.org/cases/position/position.zip" rel="external" class="download">download</a> <a target="_blank" href="http://www.ihiro.org/cases/position/" rel="external" class="demo">demo</a></p>
<p class="green"><strong>附文中jQuery的animate示例：</strong></p>
<h3>Html代码：</h3>

<div class="wp_codebox"><table><tr id="p15684"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p1568code4"><pre class="html" style="font-family:monospace;">&lt;button id=&quot;trigger&quot;&gt;Click To Animate&lt;/button&gt;
&lt;div id=&quot;box&quot;&gt;
	&lt;div class=&quot;box&quot; id=&quot;box1&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;box&quot; id=&quot;box2&quot;&gt;&lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<h3>CSS代码：</h3>

<div class="wp_codebox"><table><tr id="p15685"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1568code5"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#box</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">800px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</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: #cc66cc;">0</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;">dashed</span> <span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.box</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">120px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">40px</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;">#f60</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#390</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: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box1</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">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;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box2</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">62px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>jQuery代码：</h3>

<div class="wp_codebox"><table><tr id="p15686"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p1568code6"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#trigger'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.box'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'right'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'0'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>结果执行JS后，Firebug中实时Html代码为：<a href="http://www.ihiro.org/blog/wp-content/uploads/2010/11/firebug-code.jpg"><img src="http://www.ihiro.org/blog/wp-content/uploads/2010/11/firebug-code.jpg" alt="" title="firebug-code" width="494" height="59" class="aligncenter size-full wp-image-1570" /></a>而通过Cssviewer观察到的代码不变：<a href="http://www.ihiro.org/blog/wp-content/uploads/2010/11/cssviewer-code.jpg"><img src="http://www.ihiro.org/blog/wp-content/uploads/2010/11/cssviewer-code.jpg" alt="" title="cssviewer-code" width="284" height="147" class="aligncenter size-full wp-image-1569" /></a></p>
<p class="red">所以，不要试图用JS来改变已设定top和left的DIV的right和bottom值，当然改变top和left值还是会有效果出来的。</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2010年03月8日 -- <a href="http://www.ihiro.org/css3-basic" title="CSS:CSS3基础（附图）">CSS:CSS3基础（附图）</a> (12)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2012年01月6日 -- <a href="http://www.ihiro.org/xslt-get-the-first-last-name" title="XSLT:通过间隔符获取英文名的First Name和Last Name">XSLT:通过间隔符获取英文名的First Name和Last Name</a> (3)</li><li>2011年04月20日 -- <a href="http://www.ihiro.org/css3-transition" title="CSS3:Transition属性详解">CSS3:Transition属性详解</a> (82)</li><li>2011年04月1日 -- <a href="http://www.ihiro.org/html5-reading-note-chp4-canvas" title="HTML5:《HTML5. Up and Running》读书笔记.Chp4.Canvas">HTML5:《HTML5. Up and Running》读书笔记.Chp4.Canvas</a> (22)</li><li>2011年03月21日 -- <a href="http://www.ihiro.org/html5-reading-note-chp3-elements" title="HTML5:《HTML5. Up and Running》读书笔记.Chp3.Elements">HTML5:《HTML5. Up and Running》读书笔记.Chp3.Elements</a> (24)</li><li>2011年03月15日 -- <a href="http://www.ihiro.org/html5-reading-note-chp2-features" title="HTML5:《HTML5. Up and Running》读书笔记.Chp2.Features">HTML5:《HTML5. Up and Running》读书笔记.Chp2.Features</a> (23)</li><li>2011年03月2日 -- <a href="http://www.ihiro.org/css-specific-for-internet-explorer" title="CSS:区分IE版本的三个方法">CSS:区分IE版本的三个方法</a> (27)</li><li>2010年12月30日 -- <a href="http://www.ihiro.org/javascript-getweek-by-date" title="Javascript:根据指定日期获得星期数">Javascript:根据指定日期获得星期数</a> (23)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/css-position-hack/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>示例:Selectbox模拟实现效果</title>
		<link>http://www.ihiro.org/example-selectbox-simulation</link>
		<comments>http://www.ihiro.org/example-selectbox-simulation#comments</comments>
		<pubDate>Thu, 02 Sep 2010 15:07:01 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[CSS、XHTML]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Cases]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=1514</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/09/select_logo.png" alt="" title="select_logo" width="100" height="100" class="alignleft size-full wp-image-1515" />
<p>很长时间没有更新了，也很久没有做实例分享了。最近比较动荡，也比较忙，所以博客的更新频率也变了。</p>
<p>今天的实例算是很小的了吧，是在之前公司的公司网上做的效果，今天朋友让我扣出来给他。我便做了份，整理了分享出来给大家参考。</p>
<p>近期因新工作需要，在学习XML和XSLT相关的知识，以后也会在博客中记录一些学习笔记！</p>]]></description>
			<content:encoded><![CDATA[<p>很长时间没有更新了，也很久没有做实例分享了。最近比较动荡，也比较忙，所以博客的更新频率也变了。</p>
<p>今天的实例算是很小的了吧，是在之前公司的公司网上做的效果，今天朋友让我扣出来给他。我便做了份，整理了分享出来给大家参考。</p>
<p>近期因新工作需要，在学习XML和XSLT相关的知识，以后也会在博客中记录一些学习笔记！</p>
<p class="demo-down-bar"><a href="http://www.ihiro.org/cases/selectbox/selectbox.rar" class="download">download</a> <a href="http://www.ihiro.org/cases/selectbox/" rel="external" class="demo">demo</a></p>
<h3>一、HTML代码：</h3>
<p>
<div class="wp_codebox"><table><tr id="p15147"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p1514code7"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;selectBox&quot;&gt;
    &lt;div id=&quot;cats_seltor&quot;&gt;&lt;span&gt;全部&lt;/span&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;
    &lt;dl id=&quot;cats_lks&quot;&gt;
        &lt;dd&gt;&lt;a href=&quot;#all_svys&quot;&gt;全部&lt;/a&gt;&lt;/dd&gt;
        &lt;dd&gt;&lt;a href=&quot;#social_svys&quot;&gt;社会&lt;/a&gt;&lt;/dd&gt;
        &lt;dd&gt;&lt;a href=&quot;#emotion_svys&quot;&gt;情感&lt;/a&gt;&lt;/dd&gt;
        &lt;dd&gt;&lt;a href=&quot;#product_svys&quot;&gt;产品&lt;/a&gt;&lt;/dd&gt;
        &lt;dd&gt;&lt;a href=&quot;#happiness_svys&quot;&gt;开心&lt;/a&gt;&lt;/dd&gt;
        &lt;dd&gt;&lt;a href=&quot;#literary_svys&quot;&gt;文体&lt;/a&gt;&lt;/dd&gt;
        &lt;dd&gt;&lt;a href=&quot;#finance_svys&quot;&gt;财经&lt;/a&gt;&lt;/dd&gt;
        &lt;dd&gt;&lt;a href=&quot;#tech_svys&quot;&gt;科技&lt;/a&gt;&lt;/dd&gt;
        &lt;dd&gt;&lt;a href=&quot;#point_svys&quot;&gt;点子俱乐部&lt;/a&gt;&lt;/dd&gt;
    &lt;/dl&gt;
&lt;/div&gt;</pre></td></tr></table></div>

</p>
<h3>二、CSS代码：</h3>
<p>
<div class="wp_codebox"><table><tr id="p15148"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p1514code8"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span> Verdana<span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
a <span style="color: #00AA00;">&#123;</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>
<span style="color: #cc00cc;">#selectBox</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">116px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#cats_seltor</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;">22px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#cats_seltor</span> span<span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#cats_seltor</span> em <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;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#cats_seltor</span> span <span style="color: #00AA00;">&#123;</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;">#d4d5d8</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">74px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</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;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</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;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#f60</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#cats_seltor</span> em <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">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;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">arrow.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#cats_seltor</span> em<span style="color: #6666ff;">.down</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-30px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#cats_lks</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">114px</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;">#d4d5d8</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</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;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">22px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</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;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">10</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#cats_lks</span> dd <span style="color: #00AA00;">&#123;</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>
<span style="color: #cc00cc;">#cats_lks</span> dd 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;">#666</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;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #933;">4px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#cats_lks</span> dd 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;">#fff</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#f60</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<h3>三、jQuery代码：</h3>
<p>
<div class="wp_codebox"><table><tr id="p15149"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p1514code9"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;../js/jquery-1.4.2.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#cats_seltor'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'em'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggleClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'down'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#cats_lks'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#cats_lks a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> _text <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#cats_lks'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#cats_seltor'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>_text<span style="color: #009900;">&#41;</span>
					.<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'em'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'down'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>
</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2009年08月28日 -- <a href="http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation" title="jQuery:热点图片轮换展示效果">jQuery:热点图片轮换展示效果</a> (14)</li><li>2009年07月14日 -- <a href="http://www.ihiro.org/keyboard-simulation-with-css-and-jquery" title="jQuery:使用css+jQuery模拟键盘">jQuery:使用css+jQuery模拟键盘</a> (10)</li><li>2009年07月10日 -- <a href="http://www.ihiro.org/the-effection-of-books-show" title="jQuery:书籍展示效果">jQuery:书籍展示效果</a> (6)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/the-effection-of-tab-like-msn" title="jQuery:仿MSN网站的tab效果">jQuery:仿MSN网站的tab效果</a> (30)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/a-simple-6-lines-of-code-to-achieve-the-tab-effecttion" title="jQuery：简单6行代码实现tab效果">jQuery：简单6行代码实现tab效果</a> (10)</li><li>2009年06月30日 -- <a href="http://www.ihiro.org/the-effection-of-thunder-home-page" title="jQuery：仿迅雷首页热片滑动效果">jQuery：仿迅雷首页热片滑动效果</a> (6)</li><li>2010年02月26日 -- <a href="http://www.ihiro.org/a-rich-picture-effect-flash" title="jQuery:丰富效果的Flash图片播放（JS重写版）">jQuery:丰富效果的Flash图片播放（JS重写版）</a> (18)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2009年07月6日 -- <a href="http://www.ihiro.org/pure-css-dynamic-page-effects" title="CSS:纯css的伪动态分页效果">CSS:纯css的伪动态分页效果</a> (17)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/example-selectbox-simulation/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>CSS:Firefox 4 将支持CSS3 calc方法</title>
		<link>http://www.ihiro.org/firefox-4-will-support-css3-calc-method</link>
		<comments>http://www.ihiro.org/firefox-4-will-support-css3-calc-method#comments</comments>
		<pubDate>Sat, 12 Jun 2010 02:19:01 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[CSS、XHTML]]></category>
		<category><![CDATA[前端工程译文]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[业界信息]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=1467</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/06/firefox-4-css3-calc.jpg" alt="" title="firefox-4-css3-calc" width="100" height="100" class="alignleft size-full wp-image-1468" />
<p>该文是用来讲解CSS3中calc()方法，这一功能特性在Firefox之前的任何版本中都没曾集成，但在Firefox4版本中它将得以实现。</p>
<p>Firefox将支持CSS3 calc()，它通过一个算术表达式用来计算出一个长度值。这就意味着你可以用它来定义DIVs的大小，margins的值，borders的宽度，等等。</p>
<p>一个重要的特性是：在calc()方法的算术表达式中可以联合多个不同的单位进行计算；calc()方法支持+, -, *, /, mod, min, 和 max 运算符。</p>
<p>资料参考来自：<a href="http://hacks.mozilla.org/2010/06/css3-calc/" rel="external">http://hacks.mozilla.org/2010/06/css3-calc/</a> &#124; <a href="http://www.w3.org/TR/css3-values/#calc" rel="external">http://www.w3.org/TR/css3-values/#calc</a></p>]]></description>
			<content:encoded><![CDATA[<p>该文是用来讲解CSS3中calc()方法，这一功能特性在Firefox之前的任何版本中都没曾集成，但在Firefox4版本中它将得以实现。</p>
<p>Firefox将支持CSS3 calc()，它通过一个算术表达式用来计算出一个长度值。这就意味着你可以用它来定义DIVs的大小，margins的值，borders的宽度，等等。</p>
<h3>一、calc(<expression>) </expression></h3>
<p>例子一：下面的例子用来展示一个棘手的布局问题，通过CSS3 calc()可以轻松实现：</p>

<div class="wp_codebox"><table><tr id="p146710"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p1467code10"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
* 两个DIVs对准，外间距为1em
*/</span>
<span style="color: #cc00cc;">#a</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">75%</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;">1em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#b</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> -moz-calc<span style="color: #00AA00;">&#40;</span><span style="color: #933;">25%</span> - <span style="color: #933;">1em</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>不使用calc()的话，若通过百分比来控制宽度，并希望有1em外间距时，是无法实现的。当我们使用到外间距是，必须用页面宽度减去两个DIVs的宽度，这样的话就不够灵活了。
</p>
<p>例子二：通过calc()计算以保证一个input框的宽度不会超出其父标签的宽度：</p>

<div class="wp_codebox"><table><tr id="p146711"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p1467code11"><pre class="css" style="font-family:monospace;">input <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</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: #000000; font-weight: bold;">black</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;">width</span><span style="color: #00AA00;">:</span> -moz-calc<span style="color: #00AA00;">&#40;</span><span style="color: #933;">100%</span> - <span style="color: #cc66cc;">2</span> <span style="color: #00AA00;">*</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<p>一个重要的特性是：在calc()方法的算术表达式中可以联合多个不同的单位进行计算：</p>

<div class="wp_codebox"><table><tr id="p146712"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1467code12"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> -moz-calc<span style="color: #00AA00;">&#40;</span><span style="color: #933;">3px</span> <span style="color: #00AA00;">+</span> <span style="color: #933;">50%</span>/<span style="color: #cc66cc;">3</span> - <span style="color: #933;">3em</span> <span style="color: #00AA00;">+</span> 1rem<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></td></tr></table></div>

</p>
<p>calc()方法支持+, -, *, /, mod, min, 和 max 运算符。</p>
<h3>二、min() | max()</h3>
<p>另外：Firefox4将也支持min() 和 max()方法，使用如下：</p>

<div class="wp_codebox"><table><tr id="p146713"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1467code13"><pre class="css" style="font-family:monospace;">div <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> -moz-min<span style="color: #00AA00;">&#40;</span><span style="color: #933;">36pt</span><span style="color: #00AA00;">,</span> <span style="color: #933;">2em</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> -moz-max<span style="color: #00AA00;">&#40;</span><span style="color: #933;">50%</span><span style="color: #00AA00;">,</span> <span style="color: #933;">18px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<p>资料参考来自：<a href="http://hacks.mozilla.org/2010/06/css3-calc/" rel="external">http://hacks.mozilla.org/2010/06/css3-calc/</a> | <a href="http://www.w3.org/TR/css3-values/#calc" rel="external">http://www.w3.org/TR/css3-values/#calc</a></p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2011年11月25日 -- <a href="http://www.ihiro.org/firebug-extension-firequery" title="插件：Firebug扩展插件FireQuery">插件：Firebug扩展插件FireQuery</a> (2)</li><li>2011年03月2日 -- <a href="http://www.ihiro.org/css-specific-for-internet-explorer" title="CSS:区分IE版本的三个方法">CSS:区分IE版本的三个方法</a> (27)</li><li>2010年11月25日 -- <a href="http://www.ihiro.org/css-position-hack" title="CSS:position属性定位总结">CSS:position属性定位总结</a> (27)</li><li>2010年09月13日 -- <a href="http://www.ihiro.org/information-september-2010-programming-language-list" title="资讯:2010年09月编程语言排行榜">资讯:2010年09月编程语言排行榜</a> (23)</li><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2010年08月3日 -- <a href="http://www.ihiro.org/information-august-2010-programming-language-list" title="资讯:2010年08月编程语言排行榜">资讯:2010年08月编程语言排行榜</a> (12)</li><li>2010年07月9日 -- <a href="http://www.ihiro.org/information-july-2010-programming-language-list" title="资讯:2010年07月编程语言排行榜">资讯:2010年07月编程语言排行榜</a> (23)</li><li>2010年06月9日 -- <a href="http://www.ihiro.org/information-june-2010-programming-languages-list" title="资讯:2010年06月编程语言排行榜">资讯:2010年06月编程语言排行榜</a> (13)</li><li>2010年06月3日 -- <a href="http://www.ihiro.org/wordpress-3-new-features" title="Wordpress:3.0版本特性，将改变你的内容管理方式">Wordpress:3.0版本特性，将改变你的内容管理方式</a> (12)</li><li>2010年05月23日 -- <a href="http://www.ihiro.org/information-may-2010-programming-language-list" title="资讯:2010年05月编程语言排行榜">资讯:2010年05月编程语言排行榜</a> (23)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/firefox-4-will-support-css3-calc-method/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>CSS:通过一个样式表区分IE的各个版本</title>
		<link>http://www.ihiro.org/target-every-version-of-ie-from-a-single-stylesheet</link>
		<comments>http://www.ihiro.org/target-every-version-of-ie-from-a-single-stylesheet#comments</comments>
		<pubDate>Mon, 17 May 2010 07:47:40 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[CSS、XHTML]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[技巧]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=1430</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/05/target-ie-version.jpg" alt="" title="target-ie-version" width="100" height="100" class="alignleft size-full wp-image-1431" />
<p>通常我们知道为了修复IE各个版本与其他浏览器的兼容，在head标签内会添加条件判断，根据不同的判断结果联入不同版本的CSS样式表。</p>
<p>这样的方法在我所有的网站或者博客中都是如此应用，但我也一直在纠结着多出了多余的样式表文件，HTTP请求也就多了一个。这对于我这个做前端的是一个严重的问题，但一直都没有找到可以优化的方法。</p>
<p>但是今天我看到了一篇文章，他教会了我另一种条件判断的方法。可以用条件判断的结果来添加多余的包含标签。同时也发现，自己思考的太少了。</p>]]></description>
			<content:encoded><![CDATA[<p>通常我们知道为了修复IE各个版本与其他浏览器的兼容，在head标签内会添加条件判断，根据不同的判断结果联入不同版本的CSS样式表。如下：</p>

<div class="wp_codebox"><table><tr id="p143014"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p1430code14"><pre class="html" style="font-family:monospace;">&lt;!--[if IE 6]&gt;&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;ie6.css&quot; /&gt;&lt; ![endif]--&gt;
&lt;!--[if IE 7]&gt;&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;ie7.css&quot; /&gt;&lt; ![endif]--&gt;
&lt;!--[if IE 8]&gt;&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;ie8.css&quot; /&gt;&lt; ![endif]--&gt;</pre></td></tr></table></div>

</p>
<p>这样的方法在我所有的网站或者博客中都是如此应用，但我也一直在纠结着多出了多余的样式表文件，HTTP请求也就多了一个。这对于我这个做前端的是一个严重的问题，但一直都没有找到可以优化的方法。</p>
<p>但是今天我看到了一篇文章，他教会了我另一种条件判断的方法。可以用条件判断的结果来添加多余的包含标签。同时也发现，自己思考的太少了。实现方法如下：</p>

<div class="wp_codebox"><table><tr id="p143015"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p1430code15"><pre class="html" style="font-family:monospace;">&lt;!--[if IE 6]&gt;
	&lt;div id=&quot;ie6&quot;&gt;
&lt; ![endif]--&gt;
		&lt;div id=&quot;content&quot;&gt;
			&lt;div id=&quot;main&quot;&gt;&lt;/div&gt;
			&lt;div id=&quot;sidebar&quot;&gt;&lt;/div&gt;
		&lt;/div&gt;
		&lt;div id=&quot;footer&quot;&gt;&lt;/div&gt;
&lt;!--[if IE 6]&gt;
	&lt;/div&gt;
&lt; ![endif]--&gt;</pre></td></tr></table></div>

<p>通过这样的方法，我只需要一个样式表文件，然后在样式表中通过子选择器的方法来给出相应版本的css样式控制。如下：</p>

<div class="wp_codebox"><table><tr id="p143016"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1430code16"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#main</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;">white</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#ie6</span> <span style="color: #cc00cc;">#main</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<p>是不是你看到了也觉得惊奇呢，我就在感慨我怎么之前没有看到过这样的技巧文章了，发现原来该博主今天才更新了该文。我实在太幸运了，在我的新版主题里，我将采用这种区别IE版本的方法来控制css样式。</p>
<p class="red">追加一个Demo页面，大家可以通过IETester查看，不同版本下，样式是不一样的。</p>
<p class="demo-down-bar"><a href="http://www.ihiro.org/cases/target-ie/target-ie.rar" class="download">download</a> <a href="http://www.ihiro.org/cases/target-ie/" rel="external" class="demo">demo</a></p>
<h3>Demo的css样式：</h3>

<div class="wp_codebox"><table><tr id="p143017"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p1430code17"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">24px</span> Tahoma<span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#main</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</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;">400px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</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;">100px</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;">#ccc</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;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#ie8</span> <span style="color: #cc00cc;">#main</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;">#f00</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#f60</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#9FF</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#ie7</span> <span style="color: #cc00cc;">#main</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;">#36F</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#009</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#F0F</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#ie6</span> <span style="color: #cc00cc;">#main</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;">#f60</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#090</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFC</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>Demo的Html源码：</h3>

<div class="wp_codebox"><table><tr id="p143018"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p1430code18"><pre class="html" style="font-family:monospace;">&lt;!--[if IE 8]&gt;
	&lt;div id=&quot;ie8&quot;&gt;
&lt; ![endif]--&gt;
&lt;!--[if IE 7]&gt;
	&lt;div id=&quot;ie7&quot;&gt;
&lt; ![endif]--&gt;
&lt;!--[if IE 6]&gt;
	&lt;div id=&quot;ie6&quot;&gt;
&lt; ![endif]--&gt;
&nbsp;
	&lt;div id=&quot;main&quot;&gt;Target-IE-Version&lt;/div&gt;
&nbsp;
&lt;!--[if IE 6]&gt;
	&lt;/div&gt;
&lt; ![endif]--&gt;
&lt;!--[if IE 7]&gt;
	&lt;/div&gt;
&lt; ![endif]--&gt;
&lt;!--[if IE 8]&gt;
	&lt;/div&gt;
&lt; ![endif]--&gt;</pre></td></tr></table></div>

<p>该技巧学习自文章：<a href="http://jscariati.wordpress.com/2010/05/16/target-every-version-of-ie-from-a-single-stylesheet/" rel="external">Target Every Version of IE from a Single Stylesheet</a></p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2011年03月2日 -- <a href="http://www.ihiro.org/css-specific-for-internet-explorer" title="CSS:区分IE版本的三个方法">CSS:区分IE版本的三个方法</a> (27)</li><li>2009年09月3日 -- <a href="http://www.ihiro.org/share-some-common-techniques-of-css" title="CSS:分享一些常用的css技巧">CSS:分享一些常用的css技巧</a> (8)</li><li>2010年11月25日 -- <a href="http://www.ihiro.org/css-position-hack" title="CSS:position属性定位总结">CSS:position属性定位总结</a> (27)</li><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2010年06月12日 -- <a href="http://www.ihiro.org/firefox-4-will-support-css3-calc-method" title="CSS:Firefox 4 将支持CSS3 calc方法">CSS:Firefox 4 将支持CSS3 calc方法</a> (18)</li><li>2010年03月8日 -- <a href="http://www.ihiro.org/css3-basic" title="CSS:CSS3基础（附图）">CSS:CSS3基础（附图）</a> (12)</li><li>2010年02月20日 -- <a href="http://www.ihiro.org/how-to-insert-googlebuzz-data-into-blog" title="Wordpress:如何将GoogleBuzz数据插入到博客中">Wordpress:如何将GoogleBuzz数据插入到博客中</a> (11)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2009年09月16日 -- <a href="http://www.ihiro.org/including-wordpress-comment-reply-js" title="Wordpress:正确地引入comment-reply.js文件">Wordpress:正确地引入comment-reply.js文件</a> (23)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/target-every-version-of-ie-from-a-single-stylesheet/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>CSS:CSS3基础（附图）</title>
		<link>http://www.ihiro.org/css3-basic</link>
		<comments>http://www.ihiro.org/css3-basic#comments</comments>
		<pubDate>Mon, 08 Mar 2010 02:41:14 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[CSS、XHTML]]></category>
		<category><![CDATA[前端工程译文]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[前端工程]]></category>
		<category><![CDATA[译文]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/css-css3-based-with-photos</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/css3-basics.gif" alt="" title="css3-basics" width="100" height="100" class="alignleft size-full wp-image-1138" />
<p>今日在<a href="http://www.webdesignerwall.com/" rel="external">Web Designer Wall</a>博客上看到这篇介绍css3基础的博文，文章其实很普通，关键喜欢他配上了截图，看起来就更加明了。便花了点时间整理后发表出来与大家分享一下！</p>
<p>文中主要介绍了四个css3高级属性，也是最最常用的四个css3属性。</p>
<p>最后，css3高级属性远远不值文中的这些，文中讲到的是一些基础的，也是使用最多的，为了给用户带去更多的美好体验，努力学透css吧！</p>
<p>本文翻译自：<a href="http://www.webdesignerwall.com/tutorials/the-basics-of-css3/" rel="external">Web Designer Wall -- The Basics of CSS3</a></p>]]></description>
			<content:encoded><![CDATA[<p>今日在<a href="http://www.webdesignerwall.com/" rel="external">Web Designer Wall</a>博客上看到这篇介绍css3基础的博文，文章其实很普通，关键喜欢他配上了截图，看起来就更加明了。便花了点时间整理后发表出来与大家分享一下！</p>
<p>文中主要介绍了四个css3高级属性，也是最最常用的四个css3属性。</p>
<h3>1.RGBA</h3>
<p>RBGA是用于css的background属性，前三个参数是RBG颜色值，最后一个参数是透明度设置。<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/css3-rgba.gif" alt="" title="css3-rgba" width="470" height="276" class="aligncenter size-full wp-image-1143" />RGBA也可以使用在css中与颜色相关的所有属性中，如color,border-color,background-color,shadow-color等。<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/css3-rgba2.gif" alt="" title="css3-rgba2" width="470" height="303" class="aligncenter size-full wp-image-1144" /></p>
<h3>2.Text Shadow</h3>
<p>text-shadow的设置值是由x-offset, y-offset, blur, color四个参数组成。<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/css3-text-shadow.gif" alt="" title="css3-text-shadow" width="470" height="276" class="aligncenter size-full wp-image-1145" />若给x-offset设置一个负值，则阴影偏向左边；若个y-offset设置一个负值，则阴影偏向顶部；当然你也可以使用RGBA来设置第四个参数color。<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/css3-text-shadow-example2.gif" alt="" title="css3-text-shadow-example2" width="470" height="114" class="aligncenter size-full wp-image-1146" />你也可以给text-shadow设置一系列的值（用逗号隔开）。下面的图片展示了两个值来设置一个单词的印刷效果（1px向上，1px向下）：<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/css3-text-shadow-example3.gif" alt="" title="css3-text-shadow-example3" width="470" height="114" class="aligncenter size-full wp-image-1147" /></p>
<h3>3.Border Radius</h3>
<p>对border radius的记忆方法就和padding、margin一样(如： border-radius: 20px)。为了达到多浏览器兼容，需要在该属性前加上“-moz-“用于火狐浏览器、加上”-webkit-“用于谷歌和苹果浏览器。（IE浏览器不支持此CSS3高级属性）<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/css3-border-radius.gif" alt="" title="css3-border-radius" width="470" height="340" class="aligncenter size-full wp-image-1139" />你也可以分别设置四个角的圆角直径，火狐浏览器与苹果（谷歌)浏览器的设置属性有所差别，看图：<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/css3-border-radius-corners.gif" alt="" title="css3-border-radius-corners" width="470" height="460" class="aligncenter size-full wp-image-1140" /></p>
<h3>4.Box Shadow</h3>
<p>box shadow属性设置值的构成与text-shadow是一样的，都是有四个属性：x-offset, y-offset, blur, color组成。<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/css3-box-shadow.gif" alt="" title="css3-box-shadow" width="470" height="353" class="aligncenter size-full wp-image-1141" />当然，box-shadow也可以用一系列的值来设置属性，如：</p>

<div class="wp_codebox"><table><tr id="p114819"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1148code19"><pre class="css" style="font-family:monospace;">-moz-box-shadow<span style="color: #00AA00;">:</span>
		<span style="color: #933;">-2px</span> <span style="color: #933;">-2px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">,</span>
		<span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#bb9595</span><span style="color: #00AA00;">,</span>
		<span style="color: #933;">2px</span> <span style="color: #933;">4px</span> <span style="color: #933;">15px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> .3<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></td></tr></table></div>

<p>效果如下图：<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/css3-box-shadow2.gif" alt="" title="css3-box-shadow2" width="470" height="278" class="aligncenter size-full wp-image-1142" /></p>
<p>最后，css3高级属性远远不值文中的这些，文中讲到的是一些基础的，也是使用最多的，为了给用户带去更多的美好体验，努力学透css吧！</p>
<p>本文翻译自:<a href="http://www.webdesignerwall.com/tutorials/the-basics-of-css3/" rel="external">Web Designer Wall &#8212; The Basics of CSS3</a></p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2011年03月2日 -- <a href="http://www.ihiro.org/css-specific-for-internet-explorer" title="CSS:区分IE版本的三个方法">CSS:区分IE版本的三个方法</a> (27)</li><li>2010年11月25日 -- <a href="http://www.ihiro.org/css-position-hack" title="CSS:position属性定位总结">CSS:position属性定位总结</a> (27)</li><li>2010年03月15日 -- <a href="http://www.ihiro.org/uncovering-jquerys-hidden-features" title="jQuery:揭露jQuery的隐藏功能">jQuery:揭露jQuery的隐藏功能</a> (5)</li><li>2010年01月22日 -- <a href="http://www.ihiro.org/jquery-1-4-released-the-15-new-features-you-should-know-2" title="jQuery:1.4新版本中你应该知道的15个新特性(二)">jQuery:1.4新版本中你应该知道的15个新特性(二)</a> (7)</li><li>2010年01月20日 -- <a href="http://www.ihiro.org/jquery-1-4-released-the-15-new-features-you-should-know-1" title="jQuery:1.4新版本中你应该知道的15个新特性(一)">jQuery:1.4新版本中你应该知道的15个新特性(一)</a> (6)</li><li>2009年12月18日 -- <a href="http://www.ihiro.org/10-javascript-tips" title="Javascript:10个Javscript编程的技巧">Javascript:10个Javscript编程的技巧</a> (4)</li><li>2009年11月30日 -- <a href="http://www.ihiro.org/coding-clean-and-rich-semantic-html" title="HTML:编写干净的且富有语义的html代码">HTML:编写干净的且富有语义的html代码</a> (13)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2012年01月6日 -- <a href="http://www.ihiro.org/xslt-get-the-first-last-name" title="XSLT:通过间隔符获取英文名的First Name和Last Name">XSLT:通过间隔符获取英文名的First Name和Last Name</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/css3-basic/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</title>
		<link>http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board</link>
		<comments>http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board#comments</comments>
		<pubDate>Thu, 26 Nov 2009 15:30:43 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[案例分享]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[前端工程]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=835</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2009/11/noticeBox-thum.gif" alt="noticeBox-thum" title="noticeBox-thum" width="100" height="100" class="alignleft size-full wp-image-837" />
<p>昨天晚上收到<label style="color:#090; font-weight:bold;">随风同学</label>的求助邮件，说因上级的要求需要制作一个走马灯效果的公告栏，希望我可以帮助他解决。因看到邮件的时候都快要睡觉了，所以并没有立即处理。</p>
<p>今天早上到了公司，放开手边的工作，花了一点点时间给他制作了一个主流浏览器都兼容的走马灯公告栏。然后mail给他，但他过会儿回邮件说缺少鼠标悬停时停止的效果。于是乎有花了几分钟添加了相应的代码。到了下午快下班的时候，该同学又发来了邮件，说我的公告栏的效果有点欠缺，现在的效果和marquee标签<label style="color:#f60;">(该标签不符合W3C标准)</label>的效果一样，需要等内容上移完成后才会重复滚动，如果可以连续滚动的话那就完美了。</p>
<p>于是就在刚刚的时间我有花了几分钟的时间给他解决了，mail给他。不知道他是否还会有什么新的要求呢，期待啊！毕竟这对我来说也是一个挑战嘛，同时也帮助到了别人，何乐而不为呢！</p>]]></description>
			<content:encoded><![CDATA[<p>昨天晚上收到<label style="color:#090; font-weight:bold;">随风同学</label>的求助邮件，说因上级的要求需要制作一个走马灯效果的公告栏，希望我可以帮助他解决。因看到邮件的时候都快要睡觉了，所以并没有立即处理。</p>
<p>今天早上到了公司，放开手边的工作，花了一点点时间给他制作了一个主流浏览器都兼容的走马灯公告栏。然后mail给他，但他过会儿回邮件说缺少鼠标悬停时停止的效果。于是乎有花了几分钟添加了相应的代码。到了下午快下班的时候，该同学又发来了邮件，说我的公告栏的效果有点欠缺，现在的效果和marquee标签<label style="color:#f60;">(该标签不符合W3C标准)</label>的效果一样，需要等内容上移完成后才会重复滚动，如果可以连续滚动的话那就完美了。</p>
<p>于是就在刚刚的时间我有花了几分钟的时间给他解决了，mail给他。不知道他是否还会有什么新的要求呢，期待啊！毕竟这对我来说也是一个挑战嘛，同时也帮助到了别人，何乐而不为呢！</p>
<p>因为觉得功能差不多都实现了，所以也共享出来与大家分享，或许会对你有所帮助呢。</p>
<p class="demo-down-bar"><a href="http://www.ihiro.org/cases/noticeBox/noticeBox.rar" class="download">download</a><a href="http://www.ihiro.org/cases/noticeBox/" rel="external" class="demo">demo</a></p>
<h3>1.Html代码：</h3>

<div class="wp_codebox"><table><tr id="p83520"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p835code20"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;container&quot;&gt;
    &lt;ul class=&quot;noticeList&quot;&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/wordpress-the-article-automatically-appear-as-two&quot; title=&quot;Wordpress:将文章自动显示为两列&quot;&gt;Wordpress:将文章自动显示为两列&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/film-2012-really-have-that-day-discovery-channel-expose-for-you&quot; title=&quot;电影:《2012》真的有那一天吗？探索频道为你揭露&quot;&gt;电影:《2012》真的有那一天吗？探索频道为你揭露&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/information-november-2009-programming-language-list&quot; title=&quot;资讯:2009年11月编程语言排行榜&quot;&gt;资讯:2009年11月编程语言排行榜&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/a-busy-week-for-rent-a-house-was-finally-gaoding&quot; title=&quot;租房:忙碌一周，房子终于搞定&quot;&gt;租房:忙碌一周，房子终于搞定&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/my-third-theme-innernews&quot; title=&quot;主题:我的第三个主题innerNews提供下载&quot;&gt;主题:我的第三个主题innerNews提供下载&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/my-first-plugin-scrolltop&quot; title=&quot;插件:我的第一个插件–简约的scrollTop滑动插件&quot;&gt;插件:我的第一个插件–简约的scrollTop滑动插件&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/celebrate-my-blog-pr-catapulted-3&quot; title=&quot;PageRank:庆贺我的博客PR连升3级&quot;&gt;PageRank:庆贺我的博客PR连升3级&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/myeclipse-8-and-registration-number&quot; title=&quot;软件:MyEclipse 8.0发布，附注册码&quot;&gt;软件:MyEclipse 8.0发布，附注册码&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/tv-leng-jian&quot; title=&quot;电视:《冷箭》，让我“失眠”的谍战片&quot;&gt;电视:《冷箭》，让我“失眠”的谍战片&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/hd-is-an-attitude&quot; title=&quot;下载:高清，是一种态度！&quot;&gt;下载:高清，是一种态度！&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<h3>2.CSS代码：</h3>

<div class="wp_codebox"><table><tr id="p83521"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p835code21"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span> Verdana<span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#container</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">180px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</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;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</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;">#ccc</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">250px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.noticeList</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">180px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inside</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;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">270px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.noticeList</span> li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.noticeList</span> 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;">#606060</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>
	<span style="color: #6666ff;">.noticeList</span> 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;">#09F</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>3.JS代码：（备了部分注释，不懂的可以留言询问。）</h3>

<div class="wp_codebox"><table><tr id="p83522"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre></td><td class="code" id="p835code22"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">function</span> ScrollAction<span style="color: #009900;">&#40;</span>listObj<span style="color: #339933;">,</span> listElem<span style="color: #339933;">,</span> speed<span style="color: #339933;">,</span> isSeries<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	<span style="color: #006600; font-style: italic;">//listObj为需要滚动的列表，  speed为滚动速度</span>
		<span style="color: #003366; font-weight: bold;">var</span> pos<span style="color: #339933;">,</span> top<span style="color: #339933;">,</span> aniTop<span style="color: #339933;">,</span> height<span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">//记录setInterval的标记id</span>
&nbsp;
		pos <span style="color: #339933;">=</span> listObj.<span style="color: #660066;">position</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		top <span style="color: #339933;">=</span> pos.<span style="color: #660066;">top</span><span style="color: #339933;">;</span>			<span style="color: #006600; font-style: italic;">//列表的top</span>
		aniTop <span style="color: #339933;">=</span> top<span style="color: #339933;">;</span>				<span style="color: #006600; font-style: italic;">//记录当前运动时的top</span>
		height <span style="color: #339933;">=</span> listObj.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	<span style="color: #006600; font-style: italic;">//列表的高度</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> scrollUp <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			aniTop<span style="color: #339933;">--;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isSeries<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	<span style="color: #006600; font-style: italic;">//isSeries变量控制是否连续滚动，false不连续，true连续</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>aniTop <span style="color: #339933;">==</span> <span style="color: #339933;">-</span>height<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	<span style="color: #006600; font-style: italic;">//不连续，滚动玩重新滚动</span>
					listObj.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'top'</span><span style="color: #339933;">:</span> top<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					aniTop <span style="color: #339933;">=</span> top<span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</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>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>aniTop <span style="color: #339933;">==</span> <span style="color: #339933;">-</span>listObj.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	<span style="color: #006600; font-style: italic;">//连续滚动</span>
					<span style="color: #003366; font-weight: bold;">var</span> firstItem <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt; '</span> <span style="color: #339933;">+</span> listElem <span style="color: #339933;">+</span><span style="color: #3366CC;">'&gt;'</span> <span style="color: #339933;">+</span> listObj.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt; /'</span> <span style="color: #339933;">+</span> listElem <span style="color: #339933;">+</span><span style="color: #3366CC;">'&gt;'</span><span style="color: #339933;">;</span>
					listObj.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					listObj.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>firstItem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					aniTop <span style="color: #339933;">=</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
			listObj.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'top'</span><span style="color: #339933;">:</span> aniTop <span style="color: #339933;">+</span> <span style="color: #3366CC;">'px'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> hover <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			listObj.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				clearInterval<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				id <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</span>scrollUp<span style="color: #339933;">,</span> speed<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">start</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			id <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</span>scrollUp<span style="color: #339933;">,</span> speed<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			hover<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> sa <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ScrollAction<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.noticeList'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'li'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	sa.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p style="color:#f00;">使用时别忘了引入jQuery库哦，也希望大家给我提出意见，或功能扩充等要求。</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2010年11月25日 -- <a href="http://www.ihiro.org/css-position-hack" title="CSS:position属性定位总结">CSS:position属性定位总结</a> (27)</li><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2010年03月15日 -- <a href="http://www.ihiro.org/uncovering-jquerys-hidden-features" title="jQuery:揭露jQuery的隐藏功能">jQuery:揭露jQuery的隐藏功能</a> (5)</li><li>2010年03月8日 -- <a href="http://www.ihiro.org/css3-basic" title="CSS:CSS3基础（附图）">CSS:CSS3基础（附图）</a> (12)</li><li>2010年01月22日 -- <a href="http://www.ihiro.org/jquery-1-4-released-the-15-new-features-you-should-know-2" title="jQuery:1.4新版本中你应该知道的15个新特性(二)">jQuery:1.4新版本中你应该知道的15个新特性(二)</a> (7)</li><li>2010年01月20日 -- <a href="http://www.ihiro.org/jquery-1-4-released-the-15-new-features-you-should-know-1" title="jQuery:1.4新版本中你应该知道的15个新特性(一)">jQuery:1.4新版本中你应该知道的15个新特性(一)</a> (6)</li><li>2009年12月16日 -- <a href="http://www.ihiro.org/jquery-once-through-the-event-delegate-to-bind-a-variety-of-time-in-order-to-reduce-the-event-of-redundancy" title="jQuery:通过事件委派一次绑定多种事件，以减少事件冗余">jQuery:通过事件委派一次绑定多种事件，以减少事件冗余</a> (7)</li><li>2009年12月1日 -- <a href="http://www.ihiro.org/how-to-custom-alias-in-plugins-and-page-code" title="jQuery:如何在页面和插件代码中自定义别名">jQuery:如何在页面和插件代码中自定义别名</a> (5)</li><li>2009年08月28日 -- <a href="http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation" title="jQuery:热点图片轮换展示效果">jQuery:热点图片轮换展示效果</a> (14)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Ajax:当前页面更改内容，前端实现</title>
		<link>http://www.ihiro.org/ajax-editing-in-placing</link>
		<comments>http://www.ihiro.org/ajax-editing-in-placing#comments</comments>
		<pubDate>Wed, 23 Sep 2009 04:26:22 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[案例分享]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[前端工程]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=677</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2009/09/Ajax-Editing-150x150.jpg" alt="Ajax-Editing" title="Ajax-Editing" width="100" height="100" class="alignleft wp-image-682" />
<p>相信大家有用过Google Doc或Flickr，或者一些SNS社区的图片添加描述信息的效果，他们是在点击了一段文字后出现一个输入框，在输入框内输入你要填写的内容，点击“确认”或者“发表”即可立即显示出来。</p>
<p>今天做的这个效果呢，就是其中的截取版本。为什么这么说呢，因为我的效果只实现了前端的更改后立即发布的效果，而没有实际的与服务器端交互，也没有将输入的内容添加到数据库中，主要是为大家介绍一下实现原理。</p>
<p class="color-red">注意：源代码中没有jQuery库文件，请下载查看代码的朋友根据源代码路径自行添加。</p>]]></description>
			<content:encoded><![CDATA[<p>相信大家有用过Google Doc或Flickr，或者一些SNS社区的图片添加描述信息的效果，他们是在点击了一段文字后出现一个输入框，在输入框内输入你要填写的内容，点击“确认”或者“发表”即可立即显示出来。</p>
<p>今天做的这个效果呢，就是其中的截取版本。为什么这么说呢，因为我的效果只实现了前端的更改后立即发布的效果，而没有实际的与服务器端交互，也没有将输入的内容添加到数据库中，主要是为大家介绍一下实现原理。</p>
<p class="demo-down-bar"><a href="http://www.ihiro.org/cases/AjaxEditing/AjaxEditing.rar" class="download">download</a><a href="http://www.ihiro.org/cases/AjaxEditing/" class="demo">demo</a></p>
<h3>1.HTML代码：</h3>
<p>
<div class="wp_codebox"><table><tr id="p67723"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p677code23"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;container&quot;&gt;
  &lt;h1&gt;Ajax Editing&lt;/h1&gt;
  &lt;p&gt;鼠标移动到列表上，双击即可以进行编辑！&lt;/p&gt;
  &lt;div class=&quot;block&quot;&gt;
    &lt;h2&gt;一、电影列表&lt;/h2&gt;
    &lt;ul class=&quot;editable&quot;&gt;
      &lt;li&gt;《建国大业》，&lt;span class=&quot;color_red&quot;&gt;更新中...&lt;/span&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/film-eternal-beloved&quot;&gt;《爱有来生》&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/movie-coco-chanel&quot;&gt;《COCO Chanel》&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/one-night-in-supermarket&quot;&gt;《夜店》&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/the-legend-of-1900&quot;&gt;《海上钢琴师–1900的传说》&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/film-xinsushijian-feedback&quot;&gt;《新宿事件》&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  &lt;div class=&quot;block&quot;&gt;
    &lt;h2&gt;二、书籍列表&lt;/h2&gt;
    &lt;ul class=&quot;editable&quot;&gt;
      &lt;li&gt;《精通Javascript》&lt;/li&gt;
      &lt;li&gt;《jQuery基础教程》&lt;/li&gt;
      &lt;li&gt;《Flex入门到精通》&lt;/li&gt;
      &lt;li&gt;《PHP与MySQL Web开发》&lt;/li&gt;
      &lt;li&gt;《Google，你可以做什么》&lt;/li&gt;
      &lt;li&gt;《不抱怨的世界》&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

</p>
<h3></h3>
<p>
<div class="wp_codebox"><table><tr id="p67724"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p677code24"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span>/<span style="color: #933;">20px</span> Georgia<span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Times New Roman&quot;</span><span style="color: #00AA00;">,</span> Times<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#404040</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
h2 <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;">24px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.color_red</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;">#F00</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#container</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">1%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/* 标题样式 */</span>
	<span style="color: #cc00cc;">#container</span> h1 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">32px</span> <span style="color: #ff0000;">&quot;Lucida Sans Unicode&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Lucida Grande&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</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: #00AA00;">&#125;</span>
&nbsp;
	.<span style="color: #993333;">block</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">180px</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;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span> <span style="color: #933;">20px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/* 列表li的样式 */</span>
	ul<span style="color: #6666ff;">.editable</span> li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">list-style</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: #808080; font-style: italic;">/* 高亮当前编辑的列表li */</span>
	<span style="color: #6666ff;">.hover</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#E8F3FF</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/* 高亮当前的input输入框 */</span>
	<span style="color: #6666ff;">.editInput</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#E8F3FF</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: #00AA00;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">/* save和cancel按钮的效果，鼠标移动到上面的效果 */</span>
	<span style="color: #6666ff;">.btnSave</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.btnCancel</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">5px</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;">#09F</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#36F</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;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</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;">20px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.btnSave</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.btnCancel</span><span style="color: #3333ff;">:hover  </span><span style="color: #00AA00;">&#123;</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;">#36F</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#39F</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<h3>3. jQuery代码：</h3>
<p>
<div class="wp_codebox"><table><tr id="p67725"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code" id="p677code25"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> oldText<span style="color: #339933;">,</span> newText<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//鼠标移动到列表li上后，添加一个高亮的背景</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.editable li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hover'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hover'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'dblclick'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//获得列表li中原先的html代码</span>
		oldText <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</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;">/&quot;/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&amp;quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//将原先的html代码放在一个input中，并追加save和cancel按钮后插入到列表li中</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;input type=&quot;text&quot; class=&quot;editInput&quot; value=&quot;'</span> <span style="color: #339933;">+</span> oldText <span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot; /&gt;&lt;a href=&quot;#&quot; class=&quot;btnSave&quot;&gt;save&lt;/a&gt;&lt;a href=&quot;#&quot; class=&quot;btnCancel&quot;&gt;cancel&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'target'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'_blank'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	<span style="color: #006600; font-style: italic;">//链接在新窗口中打开</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//点击save按钮，将新的值插入在列表li中</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.btnSave'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		newText <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</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;">/&quot;/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&amp;quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>newText<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//设置超链接a的跳转为否</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//若点击cancel按钮，则将最初的html代码插入在列表li中</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.btnCancel'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>oldText<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//设置超链接a的跳转为否</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>双击列表li后，将原先列表li中的html源码保存在oldText变量中，并且在列表li标签内插入一个input输入框和两个链接作为按钮save和cancel之用；<br />
点击save按钮后，将input中的新的html源码保存在newText变量中，重新插入到列表li中，从而覆盖了列表里中的input源码；<br />
点击cancel按钮，浙江原先的html代码oldText重新插入到列表li中，覆盖掉因双击插入的input输入框和两个链接按钮。
</p>
<p class="color-red">注意：源代码中没有jQuery库文件，请下载查看代码的朋友根据源代码路径自行添加。</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2010年11月25日 -- <a href="http://www.ihiro.org/css-position-hack" title="CSS:position属性定位总结">CSS:position属性定位总结</a> (27)</li><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2010年03月25日 -- <a href="http://www.ihiro.org/the-enhanced-ajax-effect-instructions" title="Ajax:近期博客改版的增强Ajax加载说明">Ajax:近期博客改版的增强Ajax加载说明</a> (43)</li><li>2010年03月15日 -- <a href="http://www.ihiro.org/uncovering-jquerys-hidden-features" title="jQuery:揭露jQuery的隐藏功能">jQuery:揭露jQuery的隐藏功能</a> (5)</li><li>2010年03月8日 -- <a href="http://www.ihiro.org/css3-basic" title="CSS:CSS3基础（附图）">CSS:CSS3基础（附图）</a> (12)</li><li>2010年01月22日 -- <a href="http://www.ihiro.org/jquery-1-4-released-the-15-new-features-you-should-know-2" title="jQuery:1.4新版本中你应该知道的15个新特性(二)">jQuery:1.4新版本中你应该知道的15个新特性(二)</a> (7)</li><li>2010年01月20日 -- <a href="http://www.ihiro.org/jquery-1-4-released-the-15-new-features-you-should-know-1" title="jQuery:1.4新版本中你应该知道的15个新特性(一)">jQuery:1.4新版本中你应该知道的15个新特性(一)</a> (6)</li><li>2009年12月16日 -- <a href="http://www.ihiro.org/jquery-once-through-the-event-delegate-to-bind-a-variety-of-time-in-order-to-reduce-the-event-of-redundancy" title="jQuery:通过事件委派一次绑定多种事件，以减少事件冗余">jQuery:通过事件委派一次绑定多种事件，以减少事件冗余</a> (7)</li><li>2009年12月1日 -- <a href="http://www.ihiro.org/how-to-custom-alias-in-plugins-and-page-code" title="jQuery:如何在页面和插件代码中自定义别名">jQuery:如何在页面和插件代码中自定义别名</a> (5)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/ajax-editing-in-placing/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>CSS:分享一些常用的css技巧</title>
		<link>http://www.ihiro.org/share-some-common-techniques-of-css</link>
		<comments>http://www.ihiro.org/share-some-common-techniques-of-css#comments</comments>
		<pubDate>Thu, 03 Sep 2009 15:05:04 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[CSS、XHTML]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[技巧]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=538</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2009/09/common-used-css-skills.jpg" alt="common-used-css-skills" title="common-used-css-skills" width="100" height="100" class="alignleft size-full wp-image-542" />
<p>随着近几年来Web标准的流行，css也逐渐有原先辅助的角色转变成了各大网站编程的重要组成部分一直。它很好地将样式与内容分离，使得后期的版面维护与更新工作得以更加地便捷！</p>
<p>今天与大家分享一些在网站开发过程中常用到的一些css技巧，或许会给你的编写带来一些方便之处。已经知晓这些技巧的人完全可以忽略这篇文章。</p>
<p>这些css技巧或许很简单，但我的初衷是希望可以给初学者带去一些帮助。当然css技巧远远不止这些，以后会逐渐整理了发表出来与大家分享。</p>]]></description>
			<content:encoded><![CDATA[<p>随着近几年来Web标准的流行，css也逐渐有原先辅助的角色转变成了各大网站编程的重要组成部分一直。它很好地将样式与内容分离，使得后期的版面维护与更新工作得以更加地便捷！</p>
<p>今天与大家分享一些在网站开发过程中常用到的一些css技巧，或许会给你的css编写带来一些方便之处。已经知晓这些技巧的人完全可以忽略这篇文章。</p>
<h3>1. 使用!important:</h3>
<p>!important是用来将css属性的优先权提升到之高无上的地步，任何多余的装饰在!important的面前都无用无知地。使用方法：</p>

<div class="wp_codebox"><table><tr id="p53826"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p538code26"><pre class="css" style="font-family:monospace;">.<span style="color: #993333;">text</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: #000000; font-weight: bold;">blue</span> !important<span style="color: #00AA00;">;</span>   //只需在css属性后加上!important即可，与属性间的空格可有可无
        <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #993333;">red</span><span style="color: #00AA00;">;</span>  //尽管该css属性是写在后面，但没有起到任何的作用
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<h3>2. 使用background设置图片来替换文本：</h3>
<p>每个网站都有一个logo，如果使用a标签直接包含logo图片，这样的做法对搜索引擎不太友好。此时，我们可以用a标签包含一段文字，通过css来的background属性来隐藏文字，同时设置a标签的背景图片为logo图片，这样可以更加友好地优化了网站。</p>

<div class="wp_codebox"><table><tr id="p53827"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p538code27"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.logo</span> a <span style="color: #00AA00;">&#123;</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;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">120px</span><span style="color: #00AA00;">;</span>  //此处的宽度和高度与logo图片的宽度和高度一致即可
      <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span><span style="color: #00AA00;">;</span>  
      <span style="color: #000000; font-weight: bold;">text-indent</span><span style="color: #00AA00;">:</span><span style="color: #933;">-9999px</span><span style="color: #00AA00;">;</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;">'logo.gif'</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>   
 <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<h3>3. 清除浮动：</h3>
<p>在网站的布局设置时，经常会出现通过浮动来布局网站内容的分布。但若该元素浮动后，它就脱离了它的父亲的管束，会导致它的父亲的高度为0。为了不是父亲的后面的兄弟们的布局出现问题,此时需要对父亲清除浮动.方法有二:<br />
<br />01. 在父亲的浮动儿子后面插入一个块级元素,如div,设置该div的css为clear,编写css:</p>

<div class="wp_codebox"><table><tr id="p53828"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p538code28"><pre class="css" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">clear</span> <span style="color: #00AA00;">&#123;</span>
       <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span><span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>02. 使用overflow和heigth组合的方式,设置父亲father的css为:</p>

<div class="wp_codebox"><table><tr id="p53829"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p538code29"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.father</span> <span style="color: #00AA00;">&#123;</span>
       <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>  //标准浏览器中生效
       <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span>%1<span style="color: #00AA00;">;</span>    //兼容IE6
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<h3>4. 文字垂直居中</h3>
<p> 若有一个h3包含的标题，你设置了它的高度为30px，就会发现它是居上边显示的，此时你只需结合line-heigth属性即可实现居中效果：</p>

<div class="wp_codebox"><table><tr id="p53830"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p538code30"><pre class="css" style="font-family:monospace;">h3 <span style="color: #00AA00;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</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;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<h3>5. 网站整体内容居中</h3>
<p>大家都知道有个属性text-align:center;可以是文本居中，该属性在ie6下也可以实现将网站的整体居中显示。但在标准浏览器中，该属性是不起作用的。在标准浏览器中却可以使用margin:0 auto;属性是网站的整体内容居中，但该属性在IE6中却不能识别，所以为了兼容多浏览器，可以组合使用：</p>

<div class="wp_codebox"><table><tr id="p53831"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p538code31"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>    //在body标签中设置该属性给IE6认识只用
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#wrapper</span> <span style="color: #00AA00;">&#123;</span>
       <span style="color: #000000; font-weight: bold;">text-align</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</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;">margin</span>属性将网站整体内容居中
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<p>这些css技巧或许很简单，但我的初衷是希望可以给初学者带去一些帮助。当然css技巧远远不止这些，以后会逐渐整理了发表出来与大家分享。</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2011年03月2日 -- <a href="http://www.ihiro.org/css-specific-for-internet-explorer" title="CSS:区分IE版本的三个方法">CSS:区分IE版本的三个方法</a> (27)</li><li>2010年05月17日 -- <a href="http://www.ihiro.org/target-every-version-of-ie-from-a-single-stylesheet" title="CSS:通过一个样式表区分IE的各个版本">CSS:通过一个样式表区分IE的各个版本</a> (11)</li><li>2010年11月25日 -- <a href="http://www.ihiro.org/css-position-hack" title="CSS:position属性定位总结">CSS:position属性定位总结</a> (27)</li><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2010年06月12日 -- <a href="http://www.ihiro.org/firefox-4-will-support-css3-calc-method" title="CSS:Firefox 4 将支持CSS3 calc方法">CSS:Firefox 4 将支持CSS3 calc方法</a> (18)</li><li>2010年03月8日 -- <a href="http://www.ihiro.org/css3-basic" title="CSS:CSS3基础（附图）">CSS:CSS3基础（附图）</a> (12)</li><li>2010年02月20日 -- <a href="http://www.ihiro.org/how-to-insert-googlebuzz-data-into-blog" title="Wordpress:如何将GoogleBuzz数据插入到博客中">Wordpress:如何将GoogleBuzz数据插入到博客中</a> (11)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2009年09月16日 -- <a href="http://www.ihiro.org/including-wordpress-comment-reply-js" title="Wordpress:正确地引入comment-reply.js文件">Wordpress:正确地引入comment-reply.js文件</a> (23)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/share-some-common-techniques-of-css/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>jQuery:热点图片轮换展示效果</title>
		<link>http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation</link>
		<comments>http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation#comments</comments>
		<pubDate>Fri, 28 Aug 2009 08:02:54 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[案例分享]]></category>
		<category><![CDATA[Cases]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=510</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2009/08/imgPlay.jpg" alt="imgPlay" title="imgPlay" width="100" height="100" class="alignleft size-full wp-image-512" />
<p>分享一个我做的图片轮换展示效果，主要实现原理：通过设置非第一个图片的position，通过overflow:hidden属性隐藏，再使用jQuery的animate效果函数作出链性轮换的效果。</p>
<p>轮换的图片是我第一个主题的banner大图的截图版。在提供下载的压缩包里有一个png的图片是Fireworks的源文件，喜欢修改的朋友可以自行修改！另压缩包中的源码没有添加注释，不懂的请阅读本文中的注释。</p>
<p>PS：jQuery库请根据源码的路径自行加入，压缩包中不提供下载。</p>]]></description>
			<content:encoded><![CDATA[<p>分享一个我做的图片轮换展示效果，主要实现原理：通过设置非第一个图片的position，通过overflow:hidden属性隐藏，再使用jQuery的animate效果函数作出链性轮换的效果。</p>
<p>轮换的图片是我第一个主题的banner大图的截图版。在提供下载的压缩包里有一个png的图片是Fireworks的源文件，喜欢修改的朋友可以自行修改！另压缩包中的源码没有添加注释，不懂的请阅读本文中的注释。</p>
<p>PS：jQuery库请根据源码的路径自行加入，压缩包中不提供下载。</p>
<p class="demo-down-bar"><a href="http://www.ihiro.org/cases/imgPlay/imgPlay.rar" class="download" rel="external">download</a><a href="http://www.ihiro.org/cases/imgPlay/" class="demo" rel="external">demo</a></p>
<h3>1.Html代码：</h3>
<p>
<div class="wp_codebox"><table><tr id="p51032"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p510code32"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;imgs&quot;&gt;
        &lt;div class=&quot;top&quot;&gt;&lt;/div&gt;
        &lt;div class=&quot;mid&quot;&gt;
            &lt;ul&gt;
                &lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/1.jpg&quot; alt=&quot;1&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/2.jpg&quot; alt=&quot;2&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/3.jpg&quot; alt=&quot;3&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/4.jpg&quot; alt=&quot;4&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
            &lt;div id=&quot;img_list&quot;&gt;
            	&lt;a href=&quot;#1&quot; class=&quot;active&quot;&gt;1&lt;/a&gt;
            	&lt;a href=&quot;#2&quot;&gt;2&lt;/a&gt;
            	&lt;a href=&quot;#3&quot;&gt;3&lt;/a&gt;
            	&lt;a href=&quot;#4&quot;&gt;4&lt;/a&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;btm&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;</pre></td></tr></table></div>

</p>
<h3>2.Css代码：</h3>
<p>
<div class="wp_codebox"><table><tr id="p51033"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p510code33"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
img <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</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;">#eee</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">outline</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;">#imgs</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</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;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
.<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.btm</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; font-style: italic;">images/sprite.gif</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;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
.<span style="color: #000000; font-weight: bold;">top</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.btm</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">7px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.mid</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">486px</span><span style="color: #00AA00;">;</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; font-style: italic;">images/bg_img.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-y</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #933;">7px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.mid</span> ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">486px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">186px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.mid</span> ul li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">486px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">186px</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;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">490px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.mid</span> ul li<span style="color: #6666ff;">.first</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#img_list</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">486px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</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;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">1%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#img_list</span> a <span style="color: #00AA00;">&#123;</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;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-indent</span><span style="color: #00AA00;">:</span><span style="color: #933;">-9999px</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;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</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; font-style: italic;">images/sprite.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-13px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#img_list</span> a<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#img_list</span> a<span style="color: #6666ff;">.active</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-14px</span> <span style="color: #933;">-13px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<h3>3.jQuery代码：</h3>
<p>
<div class="wp_codebox"><table><tr id="p51034"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
</pre></td><td class="code" id="p510code34"><pre class="js" style="font-family:monospace;">/* start ----- play img*/
var curr = 0, next = 0, count = 0;
$(document).ready(function() {
        // 记录图片的数量	
	count = $('#img_list a').size();	
&nbsp;
	t = setInterval('imgPlay()', 3000);
&nbsp;
        // 鼠标移动到图片或导航上停止播放，移开后恢复播放	
	$('#imgs li, #img_list a').hover(function() {
		clearInterval(t);
	}, function() {
		t = setInterval('imgPlay()', 3000);
	});
&nbsp;
	//点击导航播放到相应的图片		
	$('#img_list a').click(function() {
                // index()函数返回当前导航的下标
		var index = $('#img_list a').index(this);
		if(curr != index) {
			play(index);
			curr = index;
		};
			return false;
		});	
	});
&nbsp;
	// 播放图片的函数
	var imgPlay = function() {
		next = curr + 1;
                // 若当前图片播放到最后一张，这设置下一张要播放的图片为第一张图片的下标
		if(curr == count-1) next=0;
		play(next);
&nbsp;
		curr++;
                // 在当前图片的下标加1后，若值大于最后一张图片的下标，则设置下一轮其实播放的图片下标为第一张图片的下标，而next永远比curr大1
		if(curr &gt; count-1) { curr=0; next = curr +1; }
	};
&nbsp;
	// 控制播放效果的函数
	var play = function(next) {
                // 当前的图片滑到左边-500px，完成后返回到右边490px
                // 下一张图片滑到0px处，完成后导航的焦点切换到下一个点上
		$('#imgs li').eq(curr).css({'opacity': '0.5'}).animate({'left': '-500px', 'opacity': '1'}, 'slow', function() {
				$(this).css({'left': '490px'});
			}).end()
			.eq(next).animate({'left': '0px', 'opacity': '1'}, 'slow', function() {
				$('#img_list a').siblings('a').removeClass('active').end().eq(next).addClass('active');
			});
};
/* endof ----- play img*/</pre></td></tr></table></div>
</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2009年07月14日 -- <a href="http://www.ihiro.org/keyboard-simulation-with-css-and-jquery" title="jQuery:使用css+jQuery模拟键盘">jQuery:使用css+jQuery模拟键盘</a> (10)</li><li>2009年07月10日 -- <a href="http://www.ihiro.org/the-effection-of-books-show" title="jQuery:书籍展示效果">jQuery:书籍展示效果</a> (6)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/the-effection-of-tab-like-msn" title="jQuery:仿MSN网站的tab效果">jQuery:仿MSN网站的tab效果</a> (30)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/a-simple-6-lines-of-code-to-achieve-the-tab-effecttion" title="jQuery：简单6行代码实现tab效果">jQuery：简单6行代码实现tab效果</a> (10)</li><li>2009年06月30日 -- <a href="http://www.ihiro.org/the-effection-of-thunder-home-page" title="jQuery：仿迅雷首页热片滑动效果">jQuery：仿迅雷首页热片滑动效果</a> (6)</li><li>2010年02月26日 -- <a href="http://www.ihiro.org/a-rich-picture-effect-flash" title="jQuery:丰富效果的Flash图片播放（JS重写版）">jQuery:丰富效果的Flash图片播放（JS重写版）</a> (18)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2009年07月6日 -- <a href="http://www.ihiro.org/pure-css-dynamic-page-effects" title="CSS:纯css的伪动态分页效果">CSS:纯css的伪动态分页效果</a> (17)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>jQuery:使用css+jQuery模拟键盘</title>
		<link>http://www.ihiro.org/keyboard-simulation-with-css-and-jquery</link>
		<comments>http://www.ihiro.org/keyboard-simulation-with-css-and-jquery#comments</comments>
		<pubDate>Tue, 14 Jul 2009 04:56:57 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[案例分享]]></category>
		<category><![CDATA[Cases]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[学习笔记]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=189</guid>
		<description><![CDATA[<p>今天在阅读<a href="http://net.tutsplus.com/" rel="external">Nettuts+</a>的Feed时看到了这个模拟键盘的效果，很是喜欢。便查看的源码后，了解了实现的原理，自己重新编写了CSS和JS代码，现效果如下：</p><p>
<iframe src="http://www.ihiro.org/cases/keyboard/" width="460" height="290"></iframe>
</p><p>外部链接查看效果：<a href="http://www.ihiro.org/cases/keyboard/"  rel="external">Demo</a>,源代码下载：<a href="http://www.ihiro.org/cases/keyboard/keyboard.rar"  rel="external">Download</a></p>]]></description>
			<content:encoded><![CDATA[<p>今天在阅读<a href="http://net.tutsplus.com/" rel="external">Nettuts+</a>的Feed时看到了这个模拟键盘的效果，很是喜欢。便查看的源码后，了解了实现的原理，自己重新编写了CSS和JS代码，现效果如下：</p>
<p>
<iframe src="http://www.ihiro.org/cases/keyboard/" width="460" height="290"></iframe>
</p>
<p>外部链接查看效果：<a href="http://www.ihiro.org/cases/keyboard/"  rel="external">Demo</a>,源代码下载：<a href="http://www.ihiro.org/cases/keyboard/keyboard.rar"  rel="external">Download</a></p>
<h3>1.html代码</h3>

<div class="wp_codebox"><table><tr id="p18935"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
</pre></td><td class="code" id="p189code35"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;container&quot;&gt;
	&lt;textarea id=&quot;write&quot; rows=&quot;6&quot; cols=&quot;60&quot;&gt;&lt;/textarea&gt;
	&lt;ul id=&quot;keyboard&quot;&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;~&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;!&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;@&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;#&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;$&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;%&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;^&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;&amp;amp;&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;*&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;(&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;)&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;_&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;+&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;delete lastitem&quot;&gt;delete&lt;/li&gt;
		&lt;li class=&quot;tab&quot;&gt;tab&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;q&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;w&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;e&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;r&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;t&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;y&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;u&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;i&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;o&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;p&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;{&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;}&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol lastitem&quot;&gt;&lt;span class=&quot;off&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;|&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;capslock&quot;&gt;caps lock&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;a&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;s&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;d&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;f&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;g&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;h&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;j&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;k&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;l&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;:&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;enter lastitem&quot;&gt;enter&lt;/li&gt;
		&lt;li class=&quot;left-shift&quot;&gt;shift&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;z&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;x&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;c&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;v&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;b&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;n&lt;/li&gt;
		&lt;li class=&quot;letter&quot;&gt;m&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;&lt; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;&gt;&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;symbol&quot;&gt;&lt;span class=&quot;off&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;on&quot;&gt;?&lt;/span&gt;&lt;/li&gt;
		&lt;li class=&quot;right-shift lastitem&quot;&gt;shift&lt;/li&gt;
		&lt;li class=&quot;space lastitem&quot;&gt;space&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<h3>2. CSS代码：</h3>

<div class="wp_codebox"><table><tr id="p18936"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code" id="p189code36"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> Tahoma<span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</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: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#container</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">430px</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: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #cc00cc;">#write</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">410px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">120px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</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;">5px</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;">5px</span><span style="color: #00AA00;">;</span> -moz-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> -webkit-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">5px</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;">#f9f9f9</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;">11px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
		<span style="color: #cc00cc;">#keyboard</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #cc00cc;">#keyboard</span> li <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;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</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;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</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: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> -moz-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> -webkit-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">5px</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;">#f9f9f9</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
			<span style="color: #6666ff;">.tab</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.capslock</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.left-shift</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.space</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
			<span style="color: #cc00cc;">#keyboard</span> li<span style="color: #6666ff;">.lastitem</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #cc00cc;">#keyboard</span> li<span style="color: #6666ff;">.delete</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">70px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #cc00cc;">#keyboard</span> li<span style="color: #6666ff;">.tab</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">70px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #cc00cc;">#keyboard</span> li<span style="color: #6666ff;">.capslock</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">75px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #cc00cc;">#keyboard</span> li<span style="color: #6666ff;">.enter</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">40px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #cc00cc;">#keyboard</span> li<span style="color: #6666ff;">.left-shift</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #cc00cc;">#keyboard</span> li<span style="color: #6666ff;">.right-shift</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">65px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #cc00cc;">#keyboard</span> li<span style="color: #6666ff;">.space</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">420px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
			<span style="color: #cc00cc;">#keyboard</span> li<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.hover</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">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;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#e5e5e5</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
			<span style="color: #6666ff;">.on</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			.<span style="color: #993333;">uppercase</span> <span style="color: #00AA00;">&#123;</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></pre></td></tr></table></div>

<p>为了兼容IE6和IE7，需在head标签对间加上如下代码：</p>

<div class="wp_codebox"><table><tr id="p18937"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p189code37"><pre class="html" style="font-family:monospace;">&lt;!--[if lt ie 8]&gt;
    &lt;style type=&quot;text/css&quot;&gt;
    	#write { margin-left:-10px;}
    &lt;/style&gt;
&lt; ![endif]--&gt;</pre></td></tr></table></div>

<h3>3. JS代码：</h3>

<div class="wp_codebox"><table><tr id="p18938"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
</pre></td><td class="code" id="p189code38"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> $writeBox <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#write'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		shift <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
		capslock <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#keyboard li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hover'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hover'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			charater <span style="color: #339933;">=</span> $this.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// 一键两意</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$this.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'symbol'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> charater <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span:visible'</span><span style="color: #339933;">,</span> $this<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Button detele </span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$this.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'delete'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> html <span style="color: #339933;">=</span> $writeBox.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$writeBox.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>html.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> html.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Button tab</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$this.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tab'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> charater <span style="color: #339933;">=</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\t</span>'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Button capslock</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$this.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'capslock'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.letter'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggleClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'uppercase'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			capslock <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Button enter</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$this.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'enter'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> charater <span style="color: #339933;">=</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Button shift</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$this.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'left-shift'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> $this.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'right-shift'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.letter'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggleClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'uppercase'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.symbol span'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			shift <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>shift <span style="color: #339933;">===</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">false</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			capslock <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Button space</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$this.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'space'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> charater <span style="color: #339933;">=</span> <span style="color: #3366CC;">' '</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// 转换为大写</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$this.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'uppercase'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> charater <span style="color: #339933;">=</span> charater.<span style="color: #660066;">toUpperCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// 输出所按的键值</span>
		$writeBox.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>$writeBox.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> charater<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>此效果由：<a href="http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-keyboard-with-css-and-jquery/" rel="extrenal">http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-keyboard-with-css-and-jquery/</a>中的效果改编而来。</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2009年08月28日 -- <a href="http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation" title="jQuery:热点图片轮换展示效果">jQuery:热点图片轮换展示效果</a> (14)</li><li>2009年07月10日 -- <a href="http://www.ihiro.org/the-effection-of-books-show" title="jQuery:书籍展示效果">jQuery:书籍展示效果</a> (6)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/the-effection-of-tab-like-msn" title="jQuery:仿MSN网站的tab效果">jQuery:仿MSN网站的tab效果</a> (30)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/a-simple-6-lines-of-code-to-achieve-the-tab-effecttion" title="jQuery：简单6行代码实现tab效果">jQuery：简单6行代码实现tab效果</a> (10)</li><li>2009年06月30日 -- <a href="http://www.ihiro.org/the-effection-of-thunder-home-page" title="jQuery：仿迅雷首页热片滑动效果">jQuery：仿迅雷首页热片滑动效果</a> (6)</li><li>2010年08月12日 -- <a href="http://www.ihiro.org/sizzle-custom-selector" title="Sizzle:开源JS选择器，如何自定义选择器">Sizzle:开源JS选择器，如何自定义选择器</a> (31)</li><li>2010年02月26日 -- <a href="http://www.ihiro.org/a-rich-picture-effect-flash" title="jQuery:丰富效果的Flash图片播放（JS重写版）">jQuery:丰富效果的Flash图片播放（JS重写版）</a> (18)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/keyboard-simulation-with-css-and-jquery/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>jQuery:书籍展示效果</title>
		<link>http://www.ihiro.org/the-effection-of-books-show</link>
		<comments>http://www.ihiro.org/the-effection-of-books-show#comments</comments>
		<pubDate>Fri, 10 Jul 2009 03:52:23 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[案例分享]]></category>
		<category><![CDATA[Cases]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=177</guid>
		<description><![CDATA[<p>前段时间在国外的博客上看到这个jQuery的书籍展示效果，觉得很是不错，并下载了源码，自己重新编写了CSS和JS，效果:如下</p>
<iframe src="http://www.ihiro.org/cases/bookShow/" width="520px" height="210"></iframe>
<p>说明：因为在此页面中是通过使用iframe标签引入外部页面，加上显示页面的宽度有限，所以当鼠标移动到Info图标上时，部分内容被遮盖住，这时你可以通过外部链接查看：<a href="http://www.ihiro.org/cases/bookShow/" rel="external">Demo</a></p>
<p><a href="http://www.ihiro.org/cases/bookShow/bookShow.rar" rel="external">源代码下载</a></p>]]></description>
			<content:encoded><![CDATA[<p>前段时间在国外的博客上看到这个jQuery的书籍展示效果，觉得很是不错，并下载了源码，自己重新编写了CSS和JS，效果:如下</p>
<p><iframe src="http://www.ihiro.org/cases/bookShow/" width="520" height="210"></iframe></p>
<p>说明：因为在此页面中是通过使用iframe标签引入外部页面，加上显示页面的宽度有限，所以当鼠标移动到Info图标上时，部分内容被遮盖住，这时你可以通过外部链接查看：<a href="http://www.ihiro.org/cases/bookShow/" rel="external" >Demo</a></p>
<p>具体代码实现如下：（<a href="http://www.ihiro.org/cases/bookShow/bookShow.rar" rel="external">源代码下载</a>）</p>
<h3>1.html代码:</h3>

<div class="wp_codebox"><table><tr id="p17739"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p177code39"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;books&quot;&gt;
  &lt;div class=&quot;overclear buttons&quot;&gt; 
    &lt;a href=&quot;#&quot; class=&quot;prev&quot;&gt;&lt;img src=&quot;images/books_prev.gif&quot; alt=&quot;Previous&quot; /&gt;&lt;/a&gt;
    &lt;div class=&quot;showing&quot;&gt;&lt;!-- showing --&gt;&lt;/div&gt;
    &lt;a href=&quot;#&quot; class=&quot;next&quot;&gt;&lt;img src=&quot;images/books_next.gif&quot; alt=&quot;Next&quot; /&gt;&lt;/a&gt; 
  &lt;/div&gt;
  &lt;div class=&quot;overclear top&quot;&gt;
    &lt;img src=&quot;images/books_left_top.gif&quot; alt=&quot;&quot; class=&quot;float_left&quot; /&gt;
    &lt;img src=&quot;images/books_right_top.gif&quot; alt=&quot;&quot; class=&quot;float_right&quot; /&gt;
  &lt;/div&gt;
  &lt;div class=&quot;inner&quot;&gt;
    &lt;ul class=&quot;overclear&quot;&gt;
      &lt;li class=&quot;loader&quot;&gt;&lt;!-- loader --&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  &lt;div class=&quot;overclear btm&quot;&gt;
    &lt;img src=&quot;images/books_left_btm.gif&quot; alt=&quot;&quot; class=&quot;float_left&quot; /&gt;
    &lt;img src=&quot;images/books_right_btm.gif&quot; alt=&quot;&quot; class=&quot;float_right&quot; /&gt;
  &lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<h3>2.CSS代码：</h3>

<div class="wp_codebox"><table><tr id="p17740"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code" id="p177code40"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span>/<span style="color: #933;">16px</span> Verdana<span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
img <span style="color: #00AA00;">&#123;</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: #00AA00;">&#125;</span>
a <span style="color: #00AA00;">&#123;</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: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> hide-focus<span style="color: #00AA00;">:</span>expression<span style="color: #00AA00;">&#40;</span>this.hideFocus<span style="color: #00AA00;">=</span>true<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">list-style</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;">#books</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.prev</span> img<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.next</span> img <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">40px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
.<span style="color: #000000; font-weight: bold;">top</span> img<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.btm</span> img <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.overclear</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">1%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.float_left</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: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.float_right</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: #00AA00;">&#125;</span>
.<span style="color: #000000; font-weight: bold;">top</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; font-style: italic;">images/books_top.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-x</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.btm</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; font-style: italic;">images/books_btm.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-x</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.buttons</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">32px</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;">5px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.prev</span> <span style="color: #00AA00;">&#123;</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;">top</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.next</span> <span style="color: #00AA00;">&#123;</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;">top</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.showing</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">60px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">80%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Tahoma</span><span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</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;">4px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.inner</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;">125px</span><span style="color: #00AA00;">;</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; font-style: italic;">images/books_left_mid.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-y</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.inner</span> ul <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; font-style: italic;">images/books_right_mid.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-y</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;">100%</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;">25px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.loader</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; font-style: italic;">images/books_loader.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #933;">50%</span> <span style="color: #933;">50%</span><span style="color: #00AA00;">;;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.book</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">90px</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;">padding-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.book</span> <span style="color: #6666ff;">.info</span> <span style="color: #00AA00;">&#123;</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;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">107px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">88px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.book</span> <span style="color: #6666ff;">.thumb</span> img <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #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;">#ddd</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.books-tooltip</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #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;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.books-tooltip</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.books-info</span> <span style="color: #00AA00;">&#123;</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;">#ccc</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: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">70px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>
为了兼容ie6，需在head标签内加上代码：</p>

<div class="wp_codebox"><table><tr id="p17741"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p177code41"><pre class="html" style="font-family:monospace;">&lt;!--[if lt IE 7]&gt;
&lt;style type=&quot;text/css&quot;&gt;
    .book { padding-right:12.5px;}
&lt;/style&gt;
&lt; ![end if]--&gt;</pre></td></tr></table></div>

</p>
<h3>3.xml代码：</h3>
<p>因为代码过长的原因，不在此贴出，请阅读外部链接的源代码：<a href="http://www.ihiro.org/cases/bookShow/books.xml" rel="external">XML</a></p>
<p><h3>4.jQuery代码：</h3>

<div class="wp_codebox"><table><tr id="p17742"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
</pre></td><td class="code" id="p177code42"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> perNum <span style="color: #339933;">=</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">;</span>		<span style="color: #006600; font-style: italic;">//每页显示的书本数目</span>
	<span style="color: #003366; font-weight: bold;">var</span> currentPage <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>		<span style="color: #006600; font-style: italic;">//默认显示第一页</span>
	<span style="color: #003366; font-weight: bold;">var</span> startPos <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>		<span style="color: #006600; font-style: italic;">//默认从第一本书开始显示</span>
	<span style="color: #003366; font-weight: bold;">var</span> endPos <span style="color: #339933;">=</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">;</span>			<span style="color: #006600; font-style: italic;">//显示4本书</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//从xml中获得数据，并与html结合</span>
	$.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'books.xml'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.inner ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> length <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'book'</span><span style="color: #339933;">,</span> data<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>	
&nbsp;
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'book'</span><span style="color: #339933;">,</span> data<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #003366; font-weight: bold;">var</span> $book <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> link <span style="color: #339933;">=</span> $book.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> title <span style="color: #339933;">=</span> $book.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> author <span style="color: #339933;">=</span> $book.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'author'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> imageSrc <span style="color: #339933;">=</span> $book.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'src'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> total <span style="color: #339933;">=</span> $book.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'total'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> average_rating <span style="color: #339933;">=</span> $book.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'average_rating'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #003366; font-weight: bold;">var</span> html <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&amp;lt;li class=&quot;book&quot;&amp;gt;'</span><span style="color: #339933;">;</span>
			html <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;a class=&quot;info&quot; href=&quot;'</span> <span style="color: #339933;">+</span> link <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&amp;gt;'</span><span style="color: #339933;">;</span>
			html <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;img src=&quot;images/books_info.gif&quot; alt=&quot;more info&quot; /&amp;gt;'</span><span style="color: #339933;">;</span>
			html <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;/a&amp;gt;'</span><span style="color: #339933;">;</span>			
			html <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;a class=&quot;thumb&quot; href=&quot;'</span> <span style="color: #339933;">+</span> link <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; title=&quot;'</span> <span style="color: #339933;">+</span> title <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&amp;gt;'</span><span style="color: #339933;">;</span>
			html <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;img src=&quot;'</span> <span style="color: #339933;">+</span> imageSrc <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; alt=&quot;'</span> <span style="color: #339933;">+</span>  title <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; /&amp;gt;'</span><span style="color: #339933;">;</span>
			html <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;/a&amp;gt;'</span><span style="color: #339933;">;</span>
			html <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;/li&amp;gt;'</span><span style="color: #339933;">;</span>
&nbsp;
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#books ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #003366; font-weight: bold;">var</span> bookToolTip <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&amp;lt;div id=&quot;books_ToolTip'</span> <span style="color: #339933;">+</span> index <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; class=&quot;books-tooltip&quot;&amp;gt;'</span><span style="color: #339933;">;</span>
			bookToolTip <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;div class=&quot;books_pointer_left&quot;&amp;gt;&amp;lt;/div&amp;gt;'</span><span style="color: #339933;">;</span>
			bookToolTip <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;div class=&quot;books-info&quot;&amp;gt;'</span><span style="color: #339933;">;</span>
			bookToolTip <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;p&amp;gt;'</span> <span style="color: #339933;">+</span> title <span style="color: #339933;">+</span> <span style="color: #3366CC;">'(by&amp;lt;em&amp;gt;'</span> <span style="color: #339933;">+</span> author <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&amp;lt;/em&amp;gt;)&amp;lt;/p&amp;gt;'</span><span style="color: #339933;">;</span>
			bookToolTip <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;p&amp;gt;&amp;lt;img src=&quot;images/stars_'</span> <span style="color: #339933;">+</span> average_rating <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.gif&quot; /&amp;gt;('</span> <span style="color: #339933;">+</span> total <span style="color: #339933;">+</span> <span style="color: #3366CC;">')&amp;lt;/p&amp;gt;'</span><span style="color: #339933;">;</span>
			bookToolTip <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;/div&amp;gt;'</span><span style="color: #339933;">;</span>
			bookToolTip <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&amp;lt;/div&amp;gt;'</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>bookToolTip<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//显示每页的书本</span>
		<span style="color: #003366; font-weight: bold;">var</span> show <span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>start<span style="color: #339933;">,</span> end<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>end <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> length<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				end <span style="color: #339933;">=</span> length<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.showing'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;lt;p&amp;gt;Viewing '</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>start<span style="color: #339933;">+</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' - '</span><span style="color: #339933;">+</span> end <span style="color: #339933;">+</span> <span style="color: #3366CC;">' of '</span> <span style="color: #339933;">+</span> length <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&amp;lt;/p&amp;gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.showing'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#books ul li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span>start<span style="color: #339933;">,</span> end<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>currentPage <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.prev'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fast'</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>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.prev'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fast'</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;">if</span><span style="color: #009900;">&#40;</span>currentPage <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> length <span style="color: #339933;">/</span> perNum<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.next'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fast'</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>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.next'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fast'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		show<span style="color: #009900;">&#40;</span>startPos<span style="color: #339933;">,</span> endPos<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//显示前一页</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.prev'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			currentPage <span style="color: #339933;">--;</span>
			startPos <span style="color: #339933;">=</span> perNum <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>currentPage <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			endPos <span style="color: #339933;">=</span> perNum <span style="color: #339933;">*</span> currentPage<span style="color: #339933;">;</span>
			show<span style="color: #009900;">&#40;</span>startPos<span style="color: #339933;">,</span> endPos<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//显示下一页</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.next'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			currentPage <span style="color: #339933;">++;</span>
			startPos <span style="color: #339933;">=</span> perNum <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>currentPage <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			endPos <span style="color: #339933;">=</span> perNum <span style="color: #339933;">*</span> currentPage<span style="color: #339933;">;</span>
			show<span style="color: #009900;">&#40;</span>startPos<span style="color: #339933;">,</span> endPos<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//鼠标移动到Info图标上时，显示书本的描述信息</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.info'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'opacity'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'0.9'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">//$('a.info').index(this)   获得该超链接的index</span>
			<span style="color: #003366; font-weight: bold;">var</span> offset <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #003366; font-weight: bold;">var</span> left <span style="color: #339933;">=</span> offset.<span style="color: #660066;">left</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> top <span style="color: #339933;">=</span> offset.<span style="color: #660066;">top</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#books_ToolTip'</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.info'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'opacity'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'0.7'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'left'</span><span style="color: #339933;">:</span> left<span style="color: #339933;">,</span> <span style="color: #3366CC;">'top'</span><span style="color: #339933;">:</span> top<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#books_ToolTip'</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.info'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fast'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2009年08月28日 -- <a href="http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation" title="jQuery:热点图片轮换展示效果">jQuery:热点图片轮换展示效果</a> (14)</li><li>2009年07月14日 -- <a href="http://www.ihiro.org/keyboard-simulation-with-css-and-jquery" title="jQuery:使用css+jQuery模拟键盘">jQuery:使用css+jQuery模拟键盘</a> (10)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/the-effection-of-tab-like-msn" title="jQuery:仿MSN网站的tab效果">jQuery:仿MSN网站的tab效果</a> (30)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/a-simple-6-lines-of-code-to-achieve-the-tab-effecttion" title="jQuery：简单6行代码实现tab效果">jQuery：简单6行代码实现tab效果</a> (10)</li><li>2009年06月30日 -- <a href="http://www.ihiro.org/the-effection-of-thunder-home-page" title="jQuery：仿迅雷首页热片滑动效果">jQuery：仿迅雷首页热片滑动效果</a> (6)</li><li>2010年02月26日 -- <a href="http://www.ihiro.org/a-rich-picture-effect-flash" title="jQuery:丰富效果的Flash图片播放（JS重写版）">jQuery:丰富效果的Flash图片播放（JS重写版）</a> (18)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2009年07月6日 -- <a href="http://www.ihiro.org/pure-css-dynamic-page-effects" title="CSS:纯css的伪动态分页效果">CSS:纯css的伪动态分页效果</a> (17)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/the-effection-of-books-show/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>CSS:纯css的伪动态分页效果</title>
		<link>http://www.ihiro.org/pure-css-dynamic-page-effects</link>
		<comments>http://www.ihiro.org/pure-css-dynamic-page-effects#comments</comments>
		<pubDate>Mon, 06 Jul 2009 02:29:46 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[CSS、XHTML]]></category>
		<category><![CDATA[Cases]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=139</guid>
		<description><![CDATA[<p>使用css编写的一个动态分页效果，通过使用opacity和filter实现透明效果，分页效果如下：</p>
<iframe src="http://www.ihiro.org/cases/pageNav/" width="450px" height="40px"></iframe>]]></description>
			<content:encoded><![CDATA[<p>使用css编写的一个动态分页效果，通过使用opacity和filter实现透明效果，分页效果如下：</p>
<p><iframe src="http://www.ihiro.org/cases/pageNav/" width="450px" height="40px"></iframe></p>
<h3>1.Html代码：</h3>

<div class="wp_codebox"><table><tr id="p13943"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p139code43"><pre class="html" style="font-family:monospace;">&lt;ul id=&quot;pageNav&quot;&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;arrow&quot;&gt;&lt; &lt;&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;currPage&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;3&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;6&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;7&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;8&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;9&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;10&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;11&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;12&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;13&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;14&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;15&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;arrow&quot;&gt;&gt;&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>

<h3>2.css代码：</h3>

<div class="wp_codebox"><table><tr id="p13944"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p139code44"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span> Verdana<span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</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: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
a <span style="color: #00AA00;">&#123;</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;">#pageNav</span> li <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: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#pageNav</span> li a <span style="color: #00AA00;">&#123;</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;">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;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #933;">5px</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;">#666</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;">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;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">pageNav-bg.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-x</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#pageNav</span> li a<span style="color: #6666ff;">.currPage</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#pageNav</span> li a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">4px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">-2px</span> <span style="color: #933;">-10px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> opacity<span style="color: #00AA00;">:</span>.9<span style="color: #00AA00;">;</span> filter<span style="color: #00AA00;">:</span>Alpha<span style="color: #00AA00;">&#40;</span>opacity<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">90</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#pageNav</span> li a<span style="color: #6666ff;">.arrow</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">static</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;">5px</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: #933;">-1px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>说明：本特效主要的要点在：a:hover时position:relative和margin:-2px -10px 0。为了兼容ie6，需要设置#pageNav li a { display:block; float:left;}</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2009年08月28日 -- <a href="http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation" title="jQuery:热点图片轮换展示效果">jQuery:热点图片轮换展示效果</a> (14)</li><li>2009年07月14日 -- <a href="http://www.ihiro.org/keyboard-simulation-with-css-and-jquery" title="jQuery:使用css+jQuery模拟键盘">jQuery:使用css+jQuery模拟键盘</a> (10)</li><li>2009年07月10日 -- <a href="http://www.ihiro.org/the-effection-of-books-show" title="jQuery:书籍展示效果">jQuery:书籍展示效果</a> (6)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/the-effection-of-tab-like-msn" title="jQuery:仿MSN网站的tab效果">jQuery:仿MSN网站的tab效果</a> (30)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/a-simple-6-lines-of-code-to-achieve-the-tab-effecttion" title="jQuery：简单6行代码实现tab效果">jQuery：简单6行代码实现tab效果</a> (10)</li><li>2009年06月30日 -- <a href="http://www.ihiro.org/the-effection-of-thunder-home-page" title="jQuery：仿迅雷首页热片滑动效果">jQuery：仿迅雷首页热片滑动效果</a> (6)</li><li>2011年03月2日 -- <a href="http://www.ihiro.org/css-specific-for-internet-explorer" title="CSS:区分IE版本的三个方法">CSS:区分IE版本的三个方法</a> (27)</li><li>2011年02月24日 -- <a href="http://www.ihiro.org/scroll-images" title="Javascript:图片无限循环滚动">Javascript:图片无限循环滚动</a> (27)</li><li>2010年11月25日 -- <a href="http://www.ihiro.org/css-position-hack" title="CSS:position属性定位总结">CSS:position属性定位总结</a> (27)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/pure-css-dynamic-page-effects/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>jQuery:仿MSN网站的tab效果</title>
		<link>http://www.ihiro.org/the-effection-of-tab-like-msn</link>
		<comments>http://www.ihiro.org/the-effection-of-tab-like-msn#comments</comments>
		<pubDate>Thu, 02 Jul 2009 09:51:21 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[案例分享]]></category>
		<category><![CDATA[Cases]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=134</guid>
		<description><![CDATA[今天不知怎的，一直在做tab的特效，看到MSN官网的tab效果不错，就花了一点点时间小做了一下，具体效果：如下
<iframe src="http://www.ihiro.org/cases/tabs-msn/" width="400px" height="280px" style="border:none; overflow:hidden; margin:5px 0;"></iframe>]]></description>
			<content:encoded><![CDATA[<p>今天不知怎的，一直在做tab的特效，看到MSN官网的tab效果不错，就花了一点点时间小做了一下，具体效果：如下<br />
<iframe src="http://www.ihiro.org/cases/tabs-msn/" width="400px" height="280px" style="border:none; overflow:hidden; margin:5px 0;"></iframe></p>
<h3>html代码：</h3>
<p>因为过长的原因，请有意的朋友通过此链接查看外部效果，右键查看源文件！<a href="http://www.ihiro.org/cases/tabs-msn/" rel="external">External Link</a></p>
<h3>css代码：</h3>

<div class="wp_codebox"><table><tr id="p13445"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p134code45"><pre class="css" style="font-family:monospace;">       <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span> <span style="color: #ff0000;">&quot;宋体&quot;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#049</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">8px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	a <span style="color: #00AA00;">&#123;</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: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#049</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">23px</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;">23px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #6666ff;">.popular</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">298px</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;">#ace</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
		<span style="color: #6666ff;">.tabs</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">1%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.tabs</span> li <span style="color: #00AA00;">&#123;</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;">#ace</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-width</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">1px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#f1f7fc</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">84px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</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: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.tabs</span> li<span style="color: #6666ff;">.active</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-bottom-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-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.tabs</span> li<span style="color: #6666ff;">.tab-r</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: #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;">118px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</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;">padding-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
				<span style="color: #6666ff;">.tabs</span> li<span style="color: #6666ff;">.tab-r</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;">#F06</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;">font-family</span><span style="color: #00AA00;">:</span>Georgia<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
		<span style="color: #6666ff;">.list</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">7px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">7px</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;">35px</span><span style="color: #00AA00;">;</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; font-style: italic;">popularlist.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
		<span style="color: #6666ff;">.weeklyPopular</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>jQuery代码：</h3>

<div class="wp_codebox"><table><tr id="p13446"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p134code46"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'target'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'_blank'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.tabs li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mousemove</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//最右边的tab不进行任何操作							 </span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tab-r'</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;">return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//添加当前激活的状态</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'active'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
			.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'active'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//切换tab		</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tab-0'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.list'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.dairyPopular'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		        <span style="color: #006600; font-style: italic;">//也可以写成$(this).parent().nextAll('ul:eq(0)').show();,这样的好处是不必制定特定的class类</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tab-1'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.list'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.weeklyPopular'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #006600; font-style: italic;">//也可以写成$(this).parent().nextAll('ul:eq(1)').show();,这样的好处是不必制定特定的class类</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>需要源码包的朋友可以给我留言，我会发到你的邮箱中！</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2009年08月28日 -- <a href="http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation" title="jQuery:热点图片轮换展示效果">jQuery:热点图片轮换展示效果</a> (14)</li><li>2009年07月14日 -- <a href="http://www.ihiro.org/keyboard-simulation-with-css-and-jquery" title="jQuery:使用css+jQuery模拟键盘">jQuery:使用css+jQuery模拟键盘</a> (10)</li><li>2009年07月10日 -- <a href="http://www.ihiro.org/the-effection-of-books-show" title="jQuery:书籍展示效果">jQuery:书籍展示效果</a> (6)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/a-simple-6-lines-of-code-to-achieve-the-tab-effecttion" title="jQuery：简单6行代码实现tab效果">jQuery：简单6行代码实现tab效果</a> (10)</li><li>2009年06月30日 -- <a href="http://www.ihiro.org/the-effection-of-thunder-home-page" title="jQuery：仿迅雷首页热片滑动效果">jQuery：仿迅雷首页热片滑动效果</a> (6)</li><li>2010年02月26日 -- <a href="http://www.ihiro.org/a-rich-picture-effect-flash" title="jQuery:丰富效果的Flash图片播放（JS重写版）">jQuery:丰富效果的Flash图片播放（JS重写版）</a> (18)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2009年07月6日 -- <a href="http://www.ihiro.org/pure-css-dynamic-page-effects" title="CSS:纯css的伪动态分页效果">CSS:纯css的伪动态分页效果</a> (17)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/the-effection-of-tab-like-msn/feed</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>jQuery：简单6行代码实现tab效果</title>
		<link>http://www.ihiro.org/a-simple-6-lines-of-code-to-achieve-the-tab-effecttion</link>
		<comments>http://www.ihiro.org/a-simple-6-lines-of-code-to-achieve-the-tab-effecttion#comments</comments>
		<pubDate>Thu, 02 Jul 2009 02:37:57 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[案例分享]]></category>
		<category><![CDATA[Cases]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=120</guid>
		<description><![CDATA[简简单单的6行代码实现tab滑动门效果：如下
<iframe src="http://www.ihiro.org/cases/tabs/" width="420px" height="170px" style=" overflow:hidden; border:none; margin:10px 0 10px 0;"></iframe>]]></description>
			<content:encoded><![CDATA[<p>简简单单的6行代码实现tab滑动门效果：如下<br />
<iframe src="http://www.ihiro.org/cases/tabs/" width="420px" height="170px"></iframe></p>
<h3>html代码：</h3>

<div class="wp_codebox"><table><tr id="p12047"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p120code47"><pre class="html" style="font-family:monospace;">    &lt;div class=&quot;tabs&quot;&gt;
    	&lt;!-- 默认第一个tab为激活状态 --&gt;
        &lt;h3 class=&quot;active&quot;&gt;&lt;span&gt;热点新闻&lt;/span&gt;&lt;/h3&gt;
        &lt;div id=&quot;tab-01&quot;&gt;news&lt;/div&gt;
	    &lt;h3&gt;&lt;span&gt;娱乐新闻&lt;/span&gt;&lt;/h3&gt;
        &lt;div id=&quot;tab-02&quot;&gt;enteriment&lt;/div&gt;
        &lt;h3&gt;&lt;span&gt;就业形势&lt;/span&gt;&lt;/h3&gt;
        &lt;div id=&quot;tab-03&quot;&gt;jobs&lt;/div&gt;
    &lt;/div&gt;</pre></td></tr></table></div>

<h3>CSS代码：</h3>

<div class="wp_codebox"><table><tr id="p12048"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p120code48"><pre class="css" style="font-family:monospace;">    <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
    body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span> Verdana<span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#404040</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #6666ff;">.tabs</span> <span style="color: #00AA00;">&#123;</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;">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;">360px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">1%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">140px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.tabs</span> h3 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">2</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;">12px</span><span style="color: #00AA00;">;</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; font-style: italic;">pic.gif</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;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">95px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</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;">25px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</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;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		h3<span style="color: #6666ff;">.active</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-25px</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: #00AA00;">&#125;</span>
		<span style="color: #cc00cc;">#tab-01</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#tab-02</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#tab-03</span> <span style="color: #00AA00;">&#123;</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;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">24px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">338px</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: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">93px</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;">#ace</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #cc00cc;">#tab-02</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#tab-03</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>jQuery代码：</h3>

<div class="wp_codebox"><table><tr id="p12049"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p120code49"><pre class="javascript" style="font-family:monospace;">    $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.tabs h3'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mouseover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.tabs div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'h3'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'active'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
					  .<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'active'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>具体效果也可查看：<a href="http://www.ihiro.org/cases/tabs/" rel="external">效果查看</a></p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2009年08月28日 -- <a href="http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation" title="jQuery:热点图片轮换展示效果">jQuery:热点图片轮换展示效果</a> (14)</li><li>2009年07月14日 -- <a href="http://www.ihiro.org/keyboard-simulation-with-css-and-jquery" title="jQuery:使用css+jQuery模拟键盘">jQuery:使用css+jQuery模拟键盘</a> (10)</li><li>2009年07月10日 -- <a href="http://www.ihiro.org/the-effection-of-books-show" title="jQuery:书籍展示效果">jQuery:书籍展示效果</a> (6)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/the-effection-of-tab-like-msn" title="jQuery:仿MSN网站的tab效果">jQuery:仿MSN网站的tab效果</a> (30)</li><li>2009年06月30日 -- <a href="http://www.ihiro.org/the-effection-of-thunder-home-page" title="jQuery：仿迅雷首页热片滑动效果">jQuery：仿迅雷首页热片滑动效果</a> (6)</li><li>2010年02月26日 -- <a href="http://www.ihiro.org/a-rich-picture-effect-flash" title="jQuery:丰富效果的Flash图片播放（JS重写版）">jQuery:丰富效果的Flash图片播放（JS重写版）</a> (18)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2009年07月6日 -- <a href="http://www.ihiro.org/pure-css-dynamic-page-effects" title="CSS:纯css的伪动态分页效果">CSS:纯css的伪动态分页效果</a> (17)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/a-simple-6-lines-of-code-to-achieve-the-tab-effecttion/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>jQuery：仿迅雷首页热片滑动效果</title>
		<link>http://www.ihiro.org/the-effection-of-thunder-home-page</link>
		<comments>http://www.ihiro.org/the-effection-of-thunder-home-page#comments</comments>
		<pubDate>Tue, 30 Jun 2009 14:27:39 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[案例分享]]></category>
		<category><![CDATA[Cases]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=109</guid>
		<description><![CDATA[一直都很喜欢迅雷网站的设计，前端时间迅雷更新的主页的css风格，没了以前的tab效果，多了点变幻滑动的效果。
今天花了点时间，模仿了一下当前迅雷主页上的热点电视、电影的滑动效果简简单单的6行代码实现tab滑动门效果：如下
<iframe src="http://www.ihiro.org/cases/movieshow/index.html" width="500" height="220"></iframe>]]></description>
			<content:encoded><![CDATA[<p>一直都很喜欢迅雷网站的设计，前端时间迅雷更新的主页的css风格，没了以前的tab效果，多了点变幻滑动的效果。<br />
今天花了点时间，模仿了一下当前迅雷主页上的热点电视、电影的滑动效果：如下<br />
<iframe src="http://www.ihiro.org/cases/movieshow/index.html" width="500" height="220"></iframe></p>
<h3>模仿说明：</h3>
<p>1. 因为时间的关系，没有花时间去解决ie6下图片透明的兼容；<br />
2. 在兼容各浏览器编写时花费的时间较多，实现了多浏览器的兼容性，除了图片透明的问题（时间关系）；<br />
3. 运用jQuery库对javascript进行编写；<br />
4. 采用css sprite技术处理背景定位；<br />
5. 计划实现自动播放效果。</p>
<h3>代码说明：</h3>
<p><strong>一. CSS代码：</strong></p>

<div class="wp_codebox"><table><tr id="p10950"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
</pre></td><td class="code" id="p109code50"><pre class="css" style="font-family:monospace;">html<span style="color: #00AA00;">,</span>body<span style="color: #00AA00;">,</span>
ul<span style="color: #00AA00;">,</span>ol<span style="color: #00AA00;">,</span>li<span style="color: #00AA00;">,</span>dl<span style="color: #00AA00;">,</span>dt<span style="color: #00AA00;">,</span>dd<span style="color: #00AA00;">,</span>
h1<span style="color: #00AA00;">,</span>h2<span style="color: #00AA00;">,</span>h3<span style="color: #00AA00;">,</span>h4<span style="color: #00AA00;">,</span>h5<span style="color: #00AA00;">,</span>h6<span style="color: #00AA00;">,</span>
form<span style="color: #00AA00;">,</span>input<span style="color: #00AA00;">,</span>blockquote<span style="color: #00AA00;">,</span>fieldset<span style="color: #00AA00;">,</span>pre<span style="color: #00AA00;">,</span>
div<span style="color: #00AA00;">,</span>p<span style="color: #00AA00;">,</span>span<span style="color: #00AA00;">,</span>label<span style="color: #00AA00;">,</span>em<span style="color: #00AA00;">,</span>strong <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #993333;">normal</span> <span style="color: #933;">12px</span>/<span style="color: #933;">20px</span> Arial<span style="color: #00AA00;">,</span> Verdana<span style="color: #00AA00;">,</span> Lucida<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> simsun<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#313131</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
a <span style="color: #00AA00;">&#123;</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;
&nbsp;
<span style="color: #6666ff;">.huanying</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">468px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">208px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.huanying</span> h2 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">27px</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;">27px</span><span style="color: #00AA00;">;</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; font-style: italic;">images/pic.png</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;">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;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#193b5f</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">11px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.huanying</span> .<span style="color: #000000; font-weight: bold;">content</span> <span style="color: #00AA00;">&#123;</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;">#CCDFF2</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-top-width</span><span style="color: #00AA00;">:</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;">466px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">180px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #6666ff;">.movList</span> <span style="color: #00AA00;">&#123;</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;">8px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.movList</span> ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</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;">8px</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;">432px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.movList</span> ul<span style="color: #cc00cc;">#ul_hp_0</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.movList</span> ul<span style="color: #cc00cc;">#ul_hp_1</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.movList</span> ul<span style="color: #cc00cc;">#ul_hp_2</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.movList</span> ul li <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;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">92px</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: #933;">8px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">/* ----- 封面 ----- */</span>
			<span style="color: #6666ff;">.movList</span> ul li a<span style="color: #6666ff;">.playpic</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">92px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">127px</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;">text-align</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-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.movList</span> ul li a<span style="color: #6666ff;">.playpic</span> img <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</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;">#eae4d1</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.movList</span> ul li a<span style="color: #6666ff;">.playpic</span> em <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.movList</span> ul li a<span style="color: #6666ff;">.playpic</span><span style="color: #3333ff;">:hover </span>em <span style="color: #00AA00;">&#123;</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;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">31px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">31px</span><span style="color: #00AA00;">;</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; font-style: italic;">images/pic.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #933;">-95px</span> <span style="color: #933;">-28px</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;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">48px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">30.5px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #808080; font-style: italic;">/* ----- 集数 ----- */</span>
			<span style="color: #6666ff;">.movList</span> ul li a<span style="color: #6666ff;">.playpic</span> span <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">86px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</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;">15px</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;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.movList</span> ul li a<span style="color: #6666ff;">.playpic</span> span<span style="color: #6666ff;">.bg</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; font-style: italic;">images/pic.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #933;">-130px</span> <span style="color: #933;">-28px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">/* ----- 标题和简短描述 ----- */</span>
			<span style="color: #6666ff;">.movList</span> ul li p <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">17px</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;">17px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.movList</span> ul li p<span style="color: #6666ff;">.mov-title</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">82px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.movList</span> ul li p<span style="color: #6666ff;">.mov-title</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;">#016a9f</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.movList</span> ul li p<span style="color: #6666ff;">.mov-title</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #6666ff;">.movList</span> ul li p<span style="color: #6666ff;">.mov-title</span> a<span style="color: #6666ff;">.playMov</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</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;">16px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</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; font-style: italic;">images/pic.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #933;">-240px</span> <span style="color: #933;">-28px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #6666ff;">.list-pager</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">75px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">18px</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;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.list-pager</span> a <span style="color: #00AA00;">&#123;</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;">text-indent</span><span style="color: #00AA00;">:</span><span style="color: #933;">-9999px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #808080; font-style: italic;">/* ----- page-num ----- */</span>
	<span style="color: #6666ff;">.pager-num</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">33px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">18px</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;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.pager-num</span> a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">6px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">6px</span><span style="color: #00AA00;">;</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; font-style: italic;">images/pic.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #933;">-80px</span> <span style="color: #933;">-28px</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;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">6px</span> <span style="color: #933;">5px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.pager-num</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-80px</span> <span style="color: #933;">-38px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #808080; font-style: italic;">/* ----- selected ----- */</span>
		<span style="color: #6666ff;">.currentNum</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; font-style: italic;">images/pic.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #933;">-80px</span> <span style="color: #933;">-38px</span>!important<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/* ----- prev next ----- */</span>
	<span style="color: #6666ff;">.pager-op</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;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">36px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.pager-op</span> a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">18px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">18px</span><span style="color: #00AA00;">;</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; font-style: italic;">images/pic.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.pager-op</span> a<span style="color: #6666ff;">.page-up</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;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-40px</span> <span style="color: #933;">-28px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.pager-op</span> a<span style="color: #6666ff;">.page-up</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-28px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.pager-op</span> a<span style="color: #6666ff;">.page-down</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;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-17px</span> <span style="color: #933;">-28px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #6666ff;">.pager-op</span> a<span style="color: #6666ff;">.page-down</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-57px</span> <span style="color: #933;">-28px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><strong>二. jQuery代码：</strong></p>

<div class="wp_codebox"><table><tr id="p10951"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
</pre></td><td class="code" id="p109code51"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/*
 * 时间关系，未修复IE6下图像透明的问题。
 */</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//修复IE6的：hover</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.movList ul li a.playpic'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'em'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'display'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'block'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'em'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'display'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'none'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> lenght <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#div_hp_content ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// currId-&gt;当前显示页， clickId-&gt;点击页面的标记</span>
	<span style="color: #003366; font-weight: bold;">var</span> currId <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> clickId <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// 获得需滑动的整体对象</span>
	<span style="color: #003366; font-weight: bold;">var</span> $box <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#div_hp_content ul'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>currId <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		currId <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currId <span style="color: #339933;">&gt;=</span> lenght <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		currId <span style="color: #339933;">=</span> lenght<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.pager-num a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//获得当前点击对象的id值</span>
		<span style="color: #003366; font-weight: bold;">var</span> index <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		checkIndex<span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//判断当前点击页数，若当前点击页数大于当前显示页，向左滑动</span>
		<span style="color: #006600; font-style: italic;">//若当前点击页数小于当前显示页，向右滑动</span>
		<span style="color: #006600; font-style: italic;">//否则不进行任何操作</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>clickId <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> currId<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$box.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>currId<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'-480px'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span>
						   .<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>clickId<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'10px'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>clickId <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> currId<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$box.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>currId<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'480px'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span>
						   .<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>clickId<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'10px'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//设置当前显示页标记等于点击的页数</span>
		currId <span style="color: #339933;">=</span> clickId<span style="color: #339933;">;</span>
		changeSelected<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		event.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//上一页</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.page-up'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<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>currId <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		$box.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>currId<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'480px'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span>
					   .<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>currId <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'10px'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		currId<span style="color: #339933;">--;</span>
		changeSelected<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		event.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">//下一页</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.page-down'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<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>currId <span style="color: #339933;">&gt;=</span> lenght <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		$box.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>currId<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'-480px'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span>
					   .<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>currId <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'10px'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		currId<span style="color: #339933;">++;</span>
		changeSelected<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		event.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//点击页数按钮检查index</span>
	<span style="color: #003366; font-weight: bold;">var</span> checkIndex <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">switch</span><span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'a_hp_0'</span><span style="color: #339933;">:</span>
			clickId <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'a_hp_1'</span><span style="color: #339933;">:</span>
			clickId <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'a_hp_2'</span><span style="color: #339933;">:</span>
			clickId <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//改变当前所选择的页数</span>
	<span style="color: #003366; font-weight: bold;">var</span> changeSelected <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.pager-num a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'currentNum'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>currId<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'currentNum'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>题外话：</h3>
<p>呵呵，因为图片都是从迅雷网站上下载，有点小剽窃的感觉哦。不过，在这效果上有链接到迅雷相关电视、电影页面，也算给他做个小小的推广。大家就算扯平了吧。</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2009年08月28日 -- <a href="http://www.ihiro.org/jquery-hot-pictures-showing-effects-of-rotation" title="jQuery:热点图片轮换展示效果">jQuery:热点图片轮换展示效果</a> (14)</li><li>2009年07月14日 -- <a href="http://www.ihiro.org/keyboard-simulation-with-css-and-jquery" title="jQuery:使用css+jQuery模拟键盘">jQuery:使用css+jQuery模拟键盘</a> (10)</li><li>2009年07月10日 -- <a href="http://www.ihiro.org/the-effection-of-books-show" title="jQuery:书籍展示效果">jQuery:书籍展示效果</a> (6)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/the-effection-of-tab-like-msn" title="jQuery:仿MSN网站的tab效果">jQuery:仿MSN网站的tab效果</a> (30)</li><li>2009年07月2日 -- <a href="http://www.ihiro.org/a-simple-6-lines-of-code-to-achieve-the-tab-effecttion" title="jQuery：简单6行代码实现tab效果">jQuery：简单6行代码实现tab效果</a> (10)</li><li>2010年02月26日 -- <a href="http://www.ihiro.org/a-rich-picture-effect-flash" title="jQuery:丰富效果的Flash图片播放（JS重写版）">jQuery:丰富效果的Flash图片播放（JS重写版）</a> (18)</li><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2009年07月6日 -- <a href="http://www.ihiro.org/pure-css-dynamic-page-effects" title="CSS:纯css的伪动态分页效果">CSS:纯css的伪动态分页效果</a> (17)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/the-effection-of-thunder-home-page/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
