<?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>Pablo Noel &#187; javascript</title>
	<atom:link href="http://pablonoel.com/tags/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://pablonoel.com</link>
	<description>Designer, Skater, Punk</description>
	<lastBuildDate>Tue, 10 Apr 2012 23:15:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to create transparents backgrounds with CSS and Javascript</title>
		<link>http://pablonoel.com/code/how-to-create-transparents-backgrounds-with-css-and-javascript/</link>
		<comments>http://pablonoel.com/code/how-to-create-transparents-backgrounds-with-css-and-javascript/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 21:13:48 +0000</pubDate>
		<dc:creator>Pablo Noel</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://pablonoel.com/?p=745</guid>
		<description><![CDATA[One of the most used graphic resources on the web are transparent backgrounds, the main problem with them, besides the readability of the content inside, is the always hard cross browsing, so lets see  how we can do some workarounds in order to make some nice transparent backgrounds. The &#8220;opacity&#8221; problem The simple and short [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most used graphic resources on the web are transparent backgrounds, the main problem with them, besides the readability of the content inside, is the always hard cross browsing, so lets see  how we can do some workarounds in order to make some nice transparent backgrounds.</p>
<h4>The &#8220;opacity&#8221; problem</h4>
<p>The simple and short CSS &#8220;opacity:0.5&#8243; property works just fine, at least on the most modern browsers, but affects not only the div`s background, but also the inner elements, making everything inside transparent. This can be solved by two ways.</p>
<h4>The solution from the future</h4>
<p>Using the CSS3 background property <a title="RGBA explained" href="http://www.css3.info/preview/rgba/">RBGA</a>, the only problem its this will only works with CSS3 enabled browsers.</p>
<p><strong>CSS</strong><br />
<code>div{<br />
background-color:rgba(255,255,255,0.5);<br />
}</code></p>
<h4>The solution for the past</h4>
<p>Or by a workaround using a transparent empty element positioned behind the content, like this:</p>
<p><strong>HTML</strong><br />
<code><br />
&lt;div class="trans_box"&gt;<br />
&lt;p&gt;My awesome content&lt;/p&gt;<br />
&lt;div class="trans_back"&gt;&lt;/div&gt;<br />
&lt;/div&gt;</code></p>
<p><strong>CSS</strong></p>
<p><code>.trans_box{<br />
position:relative;<br />
z-index:1;<br />
}<br />
.trans_back{<br />
position:absolute;<br />
z-index:-1<br />
top:0;<br />
left:0;<br />
width:100%;<br />
height:100%; // the height needs to be fixed in order to display correctly on ie6<br />
background:black;<br />
opacity:0.5;<br />
}</code></p>
<p>The problem, again, its this just work on modern browsers, but we have a Javascript solution for the always loved IE family</p>
<p><strong>CSS</strong></p>
<p><code>.trans_back{<br />
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; // ie8 hack<br />
filter: alpha(opacity=50); // ie6-7 hack<br />
}</code></p>
<h4>The Jquery way</h4>
<p>But hey, thats was an UGLY solution, so here it comes jQuery to saves the day. Using the same concept we can make a simple function that replace the ugliness of the hack, and will maintain the simplest html structure possible.</p>
<p><strong>HTML</strong><br />
<code>&lt;div class="trans_box"&gt;<br />
&lt;p&gt;My awesome content&lt;/p&gt;<br />
&lt;/div&gt;</code></p>
<p><strong>JS</strong><br />
<code>$('.trans_box').append('&lt;div class="trans_back"&gt;&lt;/div&gt;');<br />
$('.trans_box .trans_back').css({'opacity':0.50});</code></p>
<p><strong>CSS</strong><br />
<code>.trans_box{<br />
position:relative;<br />
z-index:1;<br />
}<br />
.trans_back{<br />
background:black;<br />
width:100%;<br />
height:100%; // the height needs to be fixed in order to display correctly on ie6<br />
position:absolute;<br />
top:0;left:0;<br />
z-index:-1;<br />
display:block;<br />
}</code></p>
<p>And thats all, i hope this little resume could save you some headaches.</p>
]]></content:encoded>
			<wfw:commentRss>http://pablonoel.com/code/how-to-create-transparents-backgrounds-with-css-and-javascript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Clean inputs on focus</title>
		<link>http://pablonoel.com/code/clean-inputs-on-focus/</link>
		<comments>http://pablonoel.com/code/clean-inputs-on-focus/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 20:58:21 +0000</pubDate>
		<dc:creator>Pablo Noel</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://pablonoel.com/?p=78</guid>
		<description><![CDATA[A fast and nice way using Jquery to clean input values on focus, and put the default value back when is empty: $(".clean").each(function(){ var value = $(this).val(); $(this).focusin(function(){if($(this).val() == value){$(this).val("");};}); $(this).focusout(function(){if($(this).val() == ''){$(this).val(value);};}); }); Just add the class &#8220;.clean&#8221; to your input tag and voilá.]]></description>
			<content:encoded><![CDATA[<p>A fast and nice way using Jquery to clean input values on focus, and put the default value back when is empty:</p>
<p><code>$(".clean").each(function(){<br />
var value = $(this).val();<br />
$(this).focusin(function(){if($(this).val() == value){$(this).val("");};});<br />
$(this).focusout(function(){if($(this).val() == ''){$(this).val(value);};});<br />
});</code></p>
<p>Just add the class &#8220;.clean&#8221; to your input tag and voilá.</p>
]]></content:encoded>
			<wfw:commentRss>http://pablonoel.com/code/clean-inputs-on-focus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

