<?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>Web Style Press, Best Practices from all the Web, Build Better Websites &#187; image effects</title>
	<atom:link href="http://www.webstylepress.com/tag/image-effects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webstylepress.com</link>
	<description>Web VS Style</description>
	<lastBuildDate>Mon, 26 Dec 2011 10:35:53 +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>Change Image Opacity Easily Using CSS or JS</title>
		<link>http://www.webstylepress.com/change-image-opacity-easily-using-css-js/</link>
		<comments>http://www.webstylepress.com/change-image-opacity-easily-using-css-js/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 09:14:06 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tricks]]></category>
		<category><![CDATA[blur]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[image effects]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[moz]]></category>
		<category><![CDATA[ns6]]></category>
		<category><![CDATA[opacity]]></category>

		<guid isPermaLink="false">http://www.webstylepress.com/?p=484</guid>
		<description><![CDATA[We can simply use CSS alone to reproduce opacity effect that have traditionally been done using scripting. The advantage of looking to CSS instead is obvious &#8211; much more lightweight and easier to implement. We can use this method where we need to use a dim or faint version of image, while when some one [...]<p><a href="http://www.webstylepress.com/change-image-opacity-easily-using-css-js/">Change Image Opacity Easily Using CSS or JS</a> is a post from: <a href="http://www.webstylepress.com">Web Style Press, Best Practices from all the Web, Build Better Websites</a></p>
]]></description>
			<content:encoded><![CDATA[<p>We can simply use CSS alone to reproduce opacity effect that have traditionally been done using scripting. The advantage of looking to CSS instead is obvious &#8211; much more lightweight and easier to implement. We can use this method where we need to use a dim or faint version of image, while when some one places mouse over it, then image comes sharp, clear and bright.</p>
<p><span id="more-484"></span></p>
<p>Use the following code in head section of web page.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&lt;style type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span><span style="color: #00AA00;">&gt;</span>
<span style="color: #6666ff;">.opacityit</span> img<span style="color: #00AA00;">&#123;</span>
filter<span style="color: #3333ff;">:progid</span><span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.Alpha<span style="color: #00AA00;">&#40;</span>opacity<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">40</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
-moz-opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0.4</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.opacityit</span><span style="color: #3333ff;">:hover </span>img<span style="color: #00AA00;">&#123;</span>
filter<span style="color: #3333ff;">:progid</span><span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.Alpha<span style="color: #00AA00;">&#40;</span>opacity<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">100</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
-moz-opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></div></div>

<p>Use the following code in body where the image is located.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;a href=&quot;#&quot; class=&quot;opacityit&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;email.gif&quot; /&gt;&lt;/a&gt;</pre></div></div>

<p>By this method image loads kind of blur in background and in light colors, but when some one places mouse over it. It becomes sharp.</p>
<p><strong>Simple Opacity</strong></p>
<p>We are using JavaScript to change the opacity of an image here. The technique works in both IE4+ and NS6+, and can be used to create some interesting &#8220;fading&#8221; effects. Here is the simple way to just place an image with opacity.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;img src=&quot;image.gif&quot; style=&quot;filter:alpha(opacity=50); -moz-opacity:0.5&quot;&gt;</pre></div></div>

<p>In <strong>-moz-opacity:0.5</strong> accepted range of values are 0 to 1, where 0 would make the image disappear and in <strong>alpha(opacity=50)</strong> range is between  1 to 100. We have combined the code both for IE and Mozilla for code compatibility.</p>
<p>We can also alter the opacity of image using javascript.</p>
<p><strong>Head section code</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> alteropacity<span style="color: #009900;">&#40;</span>imageobject<span style="color: #339933;">,</span> opacity<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>navigator.<span style="color: #660066;">appName</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Netscape&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=-</span><span style="color: #CC0000;">1</span>
  <span style="color: #339933;">&amp;&amp;</span>parseInt<span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">appVersion</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;=</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span>
    imageobject.<span style="color: #660066;">style</span>.<span style="color: #660066;">MozOpacity</span><span style="color: #339933;">=</span>opacity<span style="color: #339933;">/</span><span style="color: #CC0000;">100</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>navigator.<span style="color: #660066;">appName</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> 
  <span style="color: #339933;">&amp;&amp;</span>parseInt<span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">appVersion</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;=</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span>
    imageobject.<span style="color: #660066;">filters</span>.<span style="color: #660066;">alpha</span>.<span style="color: #660066;">opacity</span><span style="color: #339933;">=</span>opacity
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p><strong>Body Section Code</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;img src=&quot;image.gif&quot; style=&quot;filter:alpha(opacity=50); -moz-opacity:0.5&quot; 
onMouseover=&quot;alteropacity(this, 100)&quot; onMouseout=&quot;alteropacity(this, 30)&quot;&gt;</pre></div></div>

<p><a href="http://www.webstylepress.com/change-image-opacity-easily-using-css-js/">Change Image Opacity Easily Using CSS or JS</a> is a post from: <a href="http://www.webstylepress.com">Web Style Press, Best Practices from all the Web, Build Better Websites</a></p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.webstylepress.com/use-any-font-in-webpages-as-text/" title="Use Any Font in Webpages As Text">Use Any Font in Webpages As Text</a></li><li><a href="http://www.webstylepress.com/css-maximum-benefits/" title="How to Gain Maximum from CSS">How to Gain Maximum from CSS</a></li><li><a href="http://www.webstylepress.com/advanced-js-calendar/" title="Advanced JS Calendar">Advanced JS Calendar</a></li><li><a href="http://www.webstylepress.com/simple-js-calendar/" title="Create Simple Javascript Based Calendar">Create Simple Javascript Based Calendar</a></li><li><a href="http://www.webstylepress.com/javascript-essentials-part-6/" title="Javascript Essentials Part 6">Javascript Essentials Part 6</a></li><li><a href="http://www.webstylepress.com/javascript-essentials-part-5/" title="Javascript Essentials Part 5">Javascript Essentials Part 5</a></li><li><a href="http://www.webstylepress.com/javascript-essentials-part-4/" title="Javascript Essentials Part 4">Javascript Essentials Part 4</a></li><li><a href="http://www.webstylepress.com/javascript-essentials-part-3/" title="Javascript Essentials Part 3">Javascript Essentials Part 3</a></li><li><a href="http://www.webstylepress.com/javascript-essentials-part-2/" title="Javascript Essentials Part 2">Javascript Essentials Part 2</a></li><li><a href="http://www.webstylepress.com/javascript-essentials-part-1/" title="Javascript Essentials Part 1">Javascript Essentials Part 1</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.webstylepress.com/change-image-opacity-easily-using-css-js/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

