<?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>Simple happiness &#187; 菜单</title>
	<atom:link href="http://xfuxing.com/tag/%e8%8f%9c%e5%8d%95/feed" rel="self" type="application/rss+xml" />
	<link>http://xfuxing.com</link>
	<description>越简单越幸福</description>
	<lastBuildDate>Sun, 01 Jan 2012 16:55:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jquery动感菜单（导航）代码</title>
		<link>http://xfuxing.com/2009/jquery-dynamic-menu-navigation-code.html</link>
		<comments>http://xfuxing.com/2009/jquery-dynamic-menu-navigation-code.html#comments</comments>
		<pubDate>Thu, 23 Jul 2009 02:41:04 +0000</pubDate>
		<dc:creator>德海</dc:creator>
				<category><![CDATA[关注网络]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[导航]]></category>
		<category><![CDATA[菜单]]></category>

		<guid isPermaLink="false">http://xfuxing.com/abc/55</guid>
		<description><![CDATA[其实菜单（或说导航条？）有很多种，不是非要jquery不可，但有时这种菜单确实做得漂亮，虽然我下面这个菜单很简单，也是网上多个例子中的一个，但对我很实用，机制无非是用一张大图做背景，然后通过jquery来步进的移动这张背景图，造成动感。]]></description>
			<content:encoded><![CDATA[<p>其实菜单（或说导航条？）有很多种，不是非要jquery不可，但有时这种菜单确实做得漂亮，虽然我下面这个菜单很简单，也是网上多个例子中的一个，但对我很实用，机制无非是用一张大图做背景，然后通过jquery来步进的移动这张背景图，造成动感。代码中的背景图没有附上，如果您喜欢，可以自己搞一张。大小嘛，199px X 100px。<br />
<span id="more-55"></span><br />
<code><br />
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;<br />
&lt;html lang="en"&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Menu&lt;/title&gt;</p>
<p>&lt;style type="text/css"&gt;<br />
	ul {list-style:none;margin:0;padding:0;}<br />
	li {float:left;width:100px;margin:0;padding:0;text-align:center;}<br />
	li a {display:block;padding:5px 10px;height:100%;color:#FFF;text-decoration:none;border-right:1px solid #FFF;}<br />
	li a {background:url(bg2.jpg) repeat 0 0;}<br />
	li a:hover, li a:focus, li a:active {background-position:-150px 0;}<br />
	#menu a {background:url(bg.jpg) repeat -20px 35px;}</p>
<p>&lt;/style&gt;</p>
<p>&lt;script type="text/javascript" src="jquery-1.3.2.min.js"&gt;&lt;/script&gt;</p>
<p>&lt;script type="text/javascript"&gt;</p>
<p>$(function(){<br />
	$('#menu a')<br />
		.css( {backgroundPosition: "-20px 35px"} )<br />
		.mouseover(function(){<br />
			$(this).stop().animate({backgroundPosition:"(-20px 94px)"}, {duration:500})<br />
		})<br />
		.mouseout(function(){<br />
			$(this).stop().animate({backgroundPosition:"(40px 35px)"}, {duration:200, complete:function(){<br />
				$(this).css({backgroundPosition: "-20px 35px"})<br />
			}})<br />
		})<br />
});<br />
$(function($) {<br />
	$.extend($.fx.step,{<br />
	    backgroundPosition: function(fx) {<br />
            if (fx.state === 0 &#038;&#038; typeof fx.end == 'string') {<br />
                var start = $.curCSS(fx.elem,'backgroundPosition');<br />
                start = toArray(start);<br />
                fx.start = [start[0],start[2]];<br />
                var end = toArray(fx.end);<br />
                fx.end = [end[0],end[2]];<br />
                fx.unit = [end[1],end[3]];<br />
			}<br />
            var nowPosX = [];<br />
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];<br />
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];<br />
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];</p>
<p>           function toArray(strg){<br />
               strg = strg.replace(/left|top/g,'0px');<br />
               strg = strg.replace(/right|bottom/g,'100%');<br />
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");<br />
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);<br />
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];<br />
           }<br />
        }<br />
	});<br />
});<br />
&lt;/script&gt;</p>
<p>&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;div&gt;<br />
	&lt;ul id="menu"&gt;<br />
		&lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;<br />
		&lt;li&gt;&lt;a href="#"&gt;About&lt;/a&gt;&lt;/li&gt;<br />
		&lt;li&gt;&lt;a href="#"&gt;Contact&lt;/a&gt;&lt;/li&gt;<br />
	&lt;/ul&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
<p><a href="http://xfuxing.com/2009/jquery-dynamic-menu-navigation-code.html">Simple happiness</a></p>
<h3  class="related_post_title">您可能感兴趣的文章</h3><ul class="related_post"><li>2009年07月22日 -- <a href="http://xfuxing.com/2009/jquery-sliding-back-to-the-top-of-the-code.html" title="jquery滑动回顶部代码">jquery滑动回顶部代码</a> (0)</li><li>2009年07月21日 -- <a href="http://xfuxing.com/2009/jquery-interlacing-color-code.html" title="jquery隔行变色代码">jquery隔行变色代码</a> (0)</li><li>2009年07月19日 -- <a href="http://xfuxing.com/2009/jquery-option-card-code.html" title="jquery选项卡代码">jquery选项卡代码</a> (0)</li><li>2010年08月28日 -- <a href="http://xfuxing.com/2010/php-program-on-the-internationalization-i18n-of-those-things.html" title="关于php程序国际化(i18n)的那些事">关于php程序国际化(i18n)的那些事</a> (2)</li><li>2010年08月27日 -- <a href="http://xfuxing.com/2010/php-remote-file-access-to-information-under-an-important-function-get_headers.html" title="php下获取远程文件信息的重要函数get_headers">php下获取远程文件信息的重要函数get_headers</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://xfuxing.com/2009/jquery-dynamic-menu-navigation-code.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

