<?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>Script Tutorials &#187; background position | Script Tutorials | Web development</title> <atom:link href="http://www.script-tutorials.com/tag/background-position/feed/" rel="self" type="application/rss+xml" /><link>http://www.script-tutorials.com</link> <description>Tutorials for Web Developers</description> <lastBuildDate>Fri, 03 Feb 2012 06:07:51 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Positioning Backgrounds with Jquery</title><link>http://www.script-tutorials.com/positioning-background-with-jquery/</link> <comments>http://www.script-tutorials.com/positioning-background-with-jquery/#comments</comments> <pubDate>Wed, 17 Mar 2010 15:54:50 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[background position]]></category> <category><![CDATA[css]]></category> <category><![CDATA[jquery backgrounds]]></category> <category><![CDATA[navigation]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=29</guid> <description><![CDATA[Jquery Tutorial on how to Position Backgrounds Today I will tell you about another one useful tool of JQuery &#8211; backgroundPosition plugin. It allow to reach different design ideas with color/background changing. As example, we want to create animated user friendly buttons or website navigation menu. Someone can ask, why we need script if we [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/easily-animate-web-buttonsobjects-using-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/14/files/image.jpg" alt="Easily Animate Web Buttons/Objects using jQuery" /> Easily Animate Web Buttons/Objects using jQuery</a></li><li> <a
href="http://www.script-tutorials.com/multiple-backgrounds-with-css3-and-a-little-of-animation/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/76/thumb.png" alt="How to use Multiple backgrounds and Animation with CSS3" /> How to use Multiple backgrounds and Animation with CSS3</a></li><li> <a
href="http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/185/thumb.png" alt="Cool Background Image Sliding effect with jQuery" /> Cool Background Image Sliding effect with jQuery</a></li></ol></div>]]></description> <content:encoded><![CDATA[<p><strong>Jquery Tutorial on how to Position Backgrounds</strong></p><p>Today I will tell you about another one useful tool of JQuery &#8211; <a
rel="nofollow" href="http://plugins.jquery.com/project/backgroundPosition-Effect">backgroundPosition plugin</a>. It allow to reach different design ideas with color/background changing.</p><p>As example, we want to create animated user friendly buttons or website navigation menu.</p><p>Someone can ask, why we need script if we can use hover effect + CSS styles. Here you will able to compare possibilities and see advantages of JQuery.</p><p><span
id="more-29"></span></p><p>Here are Some very attractive samples:</p><ul><li><strong><a
title="Zoomimage - jQuery plugin tutorial - demo 2" rel="nofollow" href="http://www.script-tutorials.com/demos/2/source.html" target="_blank">Live Demo</a></strong></li><li><strong><a
title="Zoomimage - jQuery plugin tutorial - demo 2" rel="nofollow" href="http://www.script-tutorials.com/demos/2/source.zip">download  in package</a></strong></li></ul><hr
/><p>How to do this? Not so difficult:</p><hr
/><h3>Step 1. HTML</h3><p>Here are sources of all 5 samples. As you notice &#8211; we having simple unordered list, they all quite same, only have different &#8216;id&#8217; attribute.</p><pre class="brush:html">
&lt;ul id=&quot;ex1&quot;&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 1&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 2&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 3&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 4&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ul id=&quot;ex2&quot;&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 1&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 2&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 3&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 4&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ul id=&quot;ex3&quot;&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 1&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 2&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 3&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 4&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ul id=&quot;ex4&quot;&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 1&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 2&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 3&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 4&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ul id=&quot;ex5&quot;&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 1&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 2&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 3&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 4&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Button 5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre><hr
/><h3>Step 2. CSS</h3><pre class="brush:css">
&lt;style type=&quot;text/css&quot;&gt;
	h2 {padding-top:20px;clear:both;}
	ul {list-style:none;margin:0;padding:0;}
	li {float:left;width:100px;margin:0;padding:0;text-align:center;}
	li a {display:block;padding:5px 10px;height:100%;color:#FFF;text-decoration:none;border-right:1px solid #FFF;}
	li a:hover, li a:focus, li a:active {background-position:-150px 0;}
	li a {background:url(bg2.jpg) repeat 0 0;}
	#ex1 a {background:url(bg.jpg) repeat -20px 35px;}
	#ex2 a {background:url(bg2.jpg) repeat 0 0;}
	#ex3 a {background:url(bg3.jpg) repeat 0 0;}
	#ex4 a {background:url(bg4.jpg) repeat 0 0;}
	#ex5 a {background:url(bg4.jpg) repeat 0 0;}
&lt;/style&gt;
</pre><hr
/><h3>Step 3. JQuery</h3><pre class="brush:javascript">
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
	$('#ex1 a')
		.css( {backgroundPosition: &quot;-20px 35px&quot;} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:&quot;(-20px 94px)&quot;}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:&quot;(40px 35px)&quot;}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: &quot;-20px 35px&quot;})
			}})
		})
	$('#ex2 a')
		.css( {backgroundPosition: &quot;0 0&quot;} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:&quot;(-150px 0)&quot;}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:&quot;(-300px 0)&quot;}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: &quot;0 0&quot;})
			}})
		})
	$('#ex3 a')
		.css( {backgroundPosition: &quot;0 0&quot;} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:&quot;(0 -250px)&quot;}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:&quot;(0 0)&quot;}, {duration:500})
		})
	$('#ex4 a')
		.css( {backgroundPosition: &quot;0 0&quot;} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:&quot;(0 -250px)&quot;}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:&quot;(0 0)&quot;}, {duration:500})
		})

	$('#ex5 a')
		.css( {backgroundPosition: &quot;0 0&quot;} )
		.click(function(){
			$(this).stop().animate({backgroundPosition:&quot;(0 -250px)&quot;}, {duration:200})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:&quot;(0 0)&quot;}, {duration:500})
		})
});
&lt;/script&gt;
</pre><hr
/><h3>Step 4. Images</h3><p>Also we need few images for these demos:</p><pre class="sources">
    <img src="http://www.script-tutorials.com/demos/2/bg.jpg" alt="bg" style="" />
    <img src="http://www.script-tutorials.com/demos/2/bg2.jpg" alt="bg2" style="" />
    <img src="http://www.script-tutorials.com/demos/2/bg3.jpg" alt="bg3" style="" />
    <img src="http://www.script-tutorials.com/demos/2/bg4.jpg" alt="bg4" style="" />
</pre><hr
/><p><a
href="http://www.script-tutorials.com/demos/2/source.html" title="JQuery Background Position tutorial - demo 2" target="_blank" rel="nofollow">View Demo of our samples</a></p><p><a
href="http://www.script-tutorials.com/demos/2/source.zip" title="JQuery Background Position tutorial - demo 2" rel="nofollow">download in package</a></p><div
class="shr-publisher-29"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/easily-animate-web-buttonsobjects-using-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/14/files/image.jpg" alt="Easily Animate Web Buttons/Objects using jQuery" /> <br
/> Easily Animate Web Buttons/Objects using jQuery</a></li><li> <a
href="http://www.script-tutorials.com/multiple-backgrounds-with-css3-and-a-little-of-animation/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/76/thumb.png" alt="How to use Multiple backgrounds and Animation with CSS3" /> <br
/> How to use Multiple backgrounds and Animation with CSS3</a></li><li> <a
href="http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/185/thumb.png" alt="Cool Background Image Sliding effect with jQuery" /> <br
/> Cool Background Image Sliding effect with jQuery</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/positioning-background-with-jquery/feed/</wfw:commentRss> <slash:comments>24</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic (User agent is rejected)
Database Caching using disk: basic

Served from: www.script-tutorials.com @ 2012-02-04 21:57:21 -->
