<?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>internet mix &#187; css</title>
	<atom:link href="http://blog.ninanet.com/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.ninanet.com</link>
	<description>where&#039;s the salt?</description>
	<lastBuildDate>Wed, 07 Dec 2011 01:19:08 +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>CSS transparency inheritance workaround (PHP &amp; CSS3)</title>
		<link>http://blog.ninanet.com/2010/04/27/css-transparency-inheritance-hack</link>
		<comments>http://blog.ninanet.com/2010/04/27/css-transparency-inheritance-hack#comments</comments>
		<pubDate>Tue, 27 Apr 2010 12:00:33 +0000</pubDate>
		<dc:creator>nina</dc:creator>
				<category><![CDATA[business mix]]></category>
		<category><![CDATA[tech mix]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[opacity]]></category>
		<category><![CDATA[rgba]]></category>
		<category><![CDATA[transparency]]></category>

		<guid isPermaLink="false">http://blog.ninanet.com/?p=757</guid>
		<description><![CDATA[
After many hours reading up on the caveats of transparency; after tabbing through many suggestions found on many websites, blogs and forums; after trying to create visible containers on top of invisible containers, changing positions from relative to absolute and back only to see layout go totally awry, I finally decided to create my own [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.ninanet.com/wp-content/uploads/2010/04/transparency-compare-150x150.jpg" alt="Transparency Comparison" title="Transparency Comparison" width="150" height="150" class="alignleft size-thumbnail wp-image-764" /><br />
After many hours reading up on the caveats of transparency; after tabbing through many suggestions found on many websites, blogs and forums; after trying to create visible containers on top of invisible containers, changing positions from relative to absolute and back only to see layout go totally awry, I finally decided to create my own approach to  display <em>child elements that do not inherit the parent&#8217;s transparency setting</em>.</p>
<p>This is not a fix for every single browser out there and for every possible scenario, but it&#8217;s working in IE > 6, Firefox 3+ and our current versions of Safari  (4.0.3) and Opera (10.51).<br />
(If you come up with a variation to make it work in additional browsers, please share your findings!)</p>
<div style='clear:both;height:1px'></div>
<div style='clear:both'></div>
<div class='demobuttons'>
<p><a href='http://ninanet.com/devdemos/transparency.php' target='owin'><span class='demo'>Demo</span></a> <a href='http://ninanet.com/downloads.php?dl=8'><span class='dl'>Download</span></a></p>
<div style='clear:both'></div>
</div>
<p><span id="more-757"></span></p>
<p><strong>First, the situation:</strong></p>
<p>We have a background image and we want to make to container on top it semi-transparent (so the background image is still visible), but inside this nested container we have another item (an image, a div, etc) which we DO NOT WANT to be transparent.</p>
<div style='clear:both;height:10px'></div>
<p><strong>The two images side-by-side show the <a href="http://blog.ninanet.com/?attachment_id=760" target='owin' rel='nofollow'>desired result</a> (left, image in nested container NOT transparent) and the <a href="http://blog.ninanet.com/?attachment_id=759" target='owin' rel='nofollow'>actual result</a> (right, image in nested container is transparent):</strong></p>
<p><img src="http://blog.ninanet.com/wp-content/uploads/2010/04/transparency-compare.jpg" alt="" title="Transparency Comparison" width="500" height="250" class="alignleft size-full wp-image-764"  style='border:1px solid #cecece;padding:3px'/></p>
<div style='clear:both;height:20px'></div>
<p>The code is as follows (simplified):<br />
<strong>HTML:</strong></p>
<pre class='brush:html'>
<body>
<div class="bgdiv">
<div id="content">
<div class="servicebox">
<h1>Lorem Ipsum</h1>
<div class="serviceimg"><img src="" width="230" height="150"></div>

&lt;p&gt;In id nulla vitae nisi aliquet blandit in facilisis tellus. Duis et mauris eget enim posuere commodo. Aliquam et leo augue. Sed ut diam lacus.&lt;/p&gt;
<div class="more">read more &amp;raquo;</div>
</div>
</div>
</div>

</body>
</pre>
<p><strong>CSS:</strong></p>
<pre class='brush:css'>
.bgdiv {
	font-family:Arial, Helvetica, sans-serif;
	height:400px;
	width:400px;
	background:#ffffff url('[path-to-image]') top left no-repeat;
	padding:15px 0 0 0;
}

#content {
	min-height:340px;
	width:300px;
  	background-color:#ffffff;
	/* for IE 8 - always needs to come first */
	-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=85)";
  	/* for IE */
  	filter:alpha(opacity=85);
  	/* for FF etc */
  	opacity:0.85;
  	-moz-opacity:0.85
}

.servicebox {
	width:200px;
	margin:20px auto;
	color:#666666;
}

.servicebox h1 {
	font-family: Century Gothic,Myriad Pro,Arial,Helvetica,sans-serif;
	font-size:16px;
	color:#bf31ad;
	margin:0 0 12px 0;
	width:200px;
	line-height:12px;
	padding:10px 0;
	border-bottom:1px solid #bf31ad;
}

.serviceimg {
	border:1px solid #bfbfbf;
	width:200px;
	overflow:hidden;
	margin:0;
}

.servicebox p {
	font-size:12px;
	margin:0;
	padding: 15px 5px 5px 5px;
	color:#222222;
}

.servicebox div.more {
	text-align:center;
	color:#ffffff;
	height:20px;
	width:100px;
	margin:5px 0 0 100px;
	font-size:11px;
	line-height:18px;
	background:url('[path-to-sprite]') 0 0 no-repeat;
}

.servicebox div.more:hover {
	background:url('[path-to-sprite]') 0 -20px no-repeat;
	color:#2c8819;
}
</pre>
<p>Lines 12-14 are responsible for the transparency, we used -moz-opacity and opacity for Firefox, Safari, Opera, etc, and a filter for IE.</p>
<p>You can see everything that sits on top of (or inside) the &quot;content&quot; div automatically becomes transparent as well, no matter what you do. As mentioned above, we tried all suggestions we could find &#8211; to no avail.</p>
<p><strong>Except for these:</strong><br />
IE 7: To make the images contained in the &quot;servicebox&quot;div opaque, simply add </p>
<pre class='brush:css'>
.servicebox {position:relative;}
</pre>
<p>to the &quot;servicebox&quot;div. This won&#8217;t work in Firefox, etc, but it doesn&#8217;t hurt the layout either.</p>
<p><strong>To make it work in Firefox, Opera &amp; Safari</strong>, we had to make use of <a href="http://www.w3.org/TR/css3-color/#transparency" rel='nofollow' target='owin'>the color model in CSS3</a>:<br />
Instead of setting -moz-opacity and opacity for non-IE browsers, we added</p>
<pre class='brush:css'>
#content {background-color: rgba(255, 255, 255, 0.85);}
</pre>
<p>to the &quot;content&quot; div, where the last part (0.85) sets the <b><em>transparency/opacity level for that object only</em></b>.</p>
<p>Although browsers that don&#8217;t understand CSS3 <em>should</em> ignore it and simple move on to the next step, we experienced weird behavior when simply adding to the style sheet.</p>
<p>So we tried conditional statements, but then the code didn&#8217;t validate and we had trouble with the explicit non-IE condition {sigh}.</p>
<div style='clear:both;height:10px'></div>
<p><em>The final result was probably the easiest one (naturally <span style='color:#fe29a1'>rgba only validates against CSS3</span>, see below):</em><br />
Detect the browser with PHP (very basic) and display the required declarations (or load a browser-specific stylesheet) based on the browser detection result.</p>
<pre class='brush:php'>
&lt;?
$isIE6 = 0;
$isIE7 = 0;
$isIE8 = 0;
$ie6 = "MSIE 6.0";
$ie7 = "MSIE 7.0";
$ie8 = "MSIE 8.0";

$browser = $_SERVER['HTTP_USER_AGENT'];

if(stristr($browser, $ie6) !== false ) {
	$isIE6 = 1;
	// add any styles for IE 6 here
	// not really necessary
	// $style = "";
	/* to add a browser-specific stylesheet for IE6, simply add this:
	$style = "
<link rel=styleheet href=[yourie6stylesheet.css]>";
	*/
} elseif(stristr($browser, $ie7) !== false ) {
	$isIE7 = 1;
	// add any styles for IE 7 here
	$style = "
<style type=text/css>
	.serviceimg {
		position:relative;
	}
</style>

";
	/* to add a browser-specific stylesheet for IE7, simply add this:
	$style = "
<link rel=styleheet href=[yourie7stylesheet.css]>";
	*/
} elseif(stristr($browser, $ie8) !== false ) {
	$isIE8 = 1;
	// add any styles for IE 8 here
	$style = "
<style type=text/css>
	.serviceimg2 {position:relative;}
</style>

";
	// to add a browser-specific stylesheet for IE8, simple add this:
	// $style = "
<link rel=styleheet href=[yourie8stylesheet.css]>";

} else {
	$isIE6 = 0; $isIE7 = 0; $isIE8 = 0;
	$style= "
<style type=text/css>
	#content {background-color: rgba(255, 255, 255, 0.85);}
</style>

";
	/* to add a browser-specific stylesheet for non IE6/IE7, simply add this:
	$style = "
<link rel=styleheet href=[yourotherstylesheet.css]>";
	*/
}
?&gt;
</pre>
<div style='clear:both;height:10px'></div>
<p><strong>Super-short version  (active version on <a href="http://ninanet.com/devdemos/transparency.php" target='owin'>Demo page</a>):</strong></p>
<pre class='brush:php'>
&lt;?
$browser = $_SERVER['HTTP_USER_AGENT'];
$browsers = array("MSIE 6.0","MSIE 7.0","MSIE 8.0");
$styles = array("",".serviceimg2 {position:relative;}",".serviceimg2 {position:relative;}");
$msie= 0;

for($x = 0; $x < count($browsers);$x++) {
	if(stristr($browser, $browsers[$x]) !== false) {
		$sstyle = $styles[$x];
		$msie= 1;
	}
}
if($msie == 0 || !$msie) {
	$sstyle = "#content2 {background-color: rgba(255, 255, 255, 0.85);}";
}
$style = "
<style type=text/css>
	$sstyle
</style>

";
?&gt;
</pre>
<div style='clear:both;height:10px'></div>
<p>Insert <b>$style</b> (or its output) via shorthand PHP into your HTML code:</p>
<pre class='brush:php'>
&lt;head&gt;
	[other important things go here]
	&lt;?=$style;?&gt;
&lt;/head&gt;
</pre>
<div style='width:800px;overflow:hidden;border:1px solid #cecece'>
<a href="http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fninanet.com%2Fdevdemos%2Ftransparency.php&amp;profile=css3&amp;usermedium=all&amp;warning=1&amp;lang=en" rel='nofollow' target='owin'><img src="http://blog.ninanet.com/wp-content/uploads/2010/04/css3validated-1024x446.jpg" alt="CSS validated" title="CSS validated" width="1024" height="446" class="aligncenter size-large wp-image-841" /></a>
</div>
<div class='demobuttons'>
<p><a href='http://ninanet.com/devdemos/transparency.php' target='owin'><span class='demo'>Demo</span></a> <a href='http://ninanet.com/downloads.php?dl=8'><span class='dl'>Download</span></a></p>
<div style='clear:both'></div>
</div>
<div style="margin-top:20px;">
	<!--<div style="float:left;margin-right:10px;"><fb:send href="http%3A%2F%2Fblog.ninanet.com%2F2010%2F04%2F27%2Fcss-transparency-inheritance-hack" font=""></fb:send></div>-->
	<div style="float:left"><div id="fb-root"></div><div id="facebook_like2"> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <fb:like href=http%3A%2F%2Fblog.ninanet.com%2F2010%2F04%2F27%2Fcss-transparency-inheritance-hack show_faces="true" width="450" send="true"></fb:like></div></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.ninanet.com/2010/04/27/css-transparency-inheritance-hack/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Dress up your forms (pure CSS color-changing rounded corner input fields)</title>
		<link>http://blog.ninanet.com/2010/03/24/dress-up-your-forms2</link>
		<comments>http://blog.ninanet.com/2010/03/24/dress-up-your-forms2#comments</comments>
		<pubDate>Wed, 24 Mar 2010 14:41:39 +0000</pubDate>
		<dc:creator>nina</dc:creator>
				<category><![CDATA[tech mix]]></category>
		<category><![CDATA[:focus]]></category>
		<category><![CDATA[background-image]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://blog.ninanet.com/?p=368</guid>
		<description><![CDATA[
2) Dress up your input/text fields: rounded corners, changing colors: The easiest way ever
What you need:
a) An image sprite (if you want the colors to change)
b) A CSS class to apply to your text fields
c) The :focus pseudo-class

Basically we are using almost the same method as in the first part of the series, Dressing up [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.ninanet.com/wp-content/uploads/2010/03/blogpost1-150x150.jpg" alt="CSS Forms" title="CSS Forms" width="150" height="150" class="alignleft size-thumbnail wp-image-203" /></p>
<h3>2) Dress up your input/text fields: rounded corners, changing colors: The easiest way ever</h3>
<p>What you need:<br />
a) An image sprite (if you want the colors to change)<br />
b) A CSS class to apply to your text fields<br />
c) The :focus pseudo-class<br />
<span id="more-368"></span><br />
Basically we are using almost the same method as in the first part of the series, <a href='http://blog.ninanet.com/2010/03/22/dress-up-your-forms1'>Dressing up your Submit button</a> in which we use the :hover pseudo-class to change the background image for the submit button when the users moves the mouse over it. </p>
<p>We cannot use the :hover class for text fields, we will be using the :focus pseudo-class instead. :focus gets triggered when a user places the cursor inside a text field (related to JavaScript&#8217;s focus() method). </p>
<p>The sprite we are using is the following:<br />
<a href="http://blog.ninanet.com/wp-includes/images//txtfld1.png" rel="wp-prettyPhoto[g368]"><img alt="Textfield Sprite" src="http://blog.ninanet.com/wp-includes/images//txtfld1.png" title="Textfield Sprite" class="alignnone" width="274" height="60" /></a></p>
<p>Let&#8217;s create a simple text input field and assign the class &#8220;txtfld&#8221; to it:</p>
<pre class='brush:css'>
<input type="text" value="" size="22" class="txtfld"/>
</pre>
<p>The CSS gives the field its refined look:</p>
<pre class='brush:css'>
.txtfld {
	font:1.1em  Verdana, Arial, Helvetica, sans-serif ;
	width:274px;
	height:24px;
	border:0;
	background:url("path-to-your-image-file") no-repeat 0 0;
	color:#FFFFFF;
}
</pre>
<p>1: Define the txtfld class<br />
2: Font declaration shorthand:<br />
enlarge font size to 1.1<br />
use Verdana, Arial, Helvetica and make sure if none of these are available that we are still using a font without serifs (sans-serif)<br />
3: Set the width of the field<br />
4: Set the height of the field<br />
5: Set the border to 0, otherwise the browser will display the default border around the element<br />
6: Shorthand background definition:<br />
Set the path to the sprite<br />
Don&#8217;t repeat the image<br />
Start displaying the image 0px from the top and 0px from the left (you can always use &#8220;top&#8221; and &#8220;left&#8221; instead of 0px &#8212; without the quotes)<br />
7: Set the font color for the text inside the field (white)</p>
<p>Similar to the technique used to change the background image for the submit button, we use another pseudo-class to change the background image when the user places the cursor inside:</p>
<pre class='brush:css'>
.txtfld:focus {
	background:url("path-to-your-image-file") no-repeat 0 -30px;
}
</pre>
<p>All this code does is tell the browser to display a different part of the sprite, starting at 0px from the left (like before) but only show the part of the image starting 30px from the top. You can use &#8220;left -30px&#8221; to achieve the same result.</p>
<p>You can see the effect when you click in one of the field in the comment form at the bottom of this post.</p>
<div style='clear:both:height:15px;'></div>
<p>Note/Disclaimer:<br />
IE 6 AND IE 7 will display the background image, but since they don&#8217;t recognize the :hover pseudo-class the background does not change.<br />
IE 7 finally does understand Alpha transparency in PNG files, but again, if you do want your form fields to look halfway decent in IE 6, create the images with a matching background. </p>
<div style='clear:both:height:20px;'></div>
<div style="margin-top:20px;">
	<!--<div style="float:left;margin-right:10px;"><fb:send href="http%3A%2F%2Fblog.ninanet.com%2F2010%2F03%2F24%2Fdress-up-your-forms2" font=""></fb:send></div>-->
	<div style="float:left"><div id="fb-root"></div><div id="facebook_like4"> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <fb:like href=http%3A%2F%2Fblog.ninanet.com%2F2010%2F03%2F24%2Fdress-up-your-forms2 show_faces="true" width="450" send="true"></fb:like></div></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.ninanet.com/2010/03/24/dress-up-your-forms2/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dress up your forms (pure CSS submit button)</title>
		<link>http://blog.ninanet.com/2010/03/22/dress-up-your-forms1</link>
		<comments>http://blog.ninanet.com/2010/03/22/dress-up-your-forms1#comments</comments>
		<pubDate>Mon, 22 Mar 2010 20:20:20 +0000</pubDate>
		<dc:creator>nina</dc:creator>
				<category><![CDATA[tech mix]]></category>
		<category><![CDATA[background-image]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[submit]]></category>

		<guid isPermaLink="false">http://blog.ninanet.com/?p=201</guid>
		<description><![CDATA[
The days where forms had to be boring are definitely over. Instead, forms can and should be part of the overall design. 
We are not designers, we just like pretty things (and pretty code). And we like it best if it all is functional and adds to the experience without limiting it. And while we [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.ninanet.com/wp-content/uploads/2010/03/blogpost1-150x150.jpg" alt="" title="CSS Forms" width="150" height="150" class="alignleft size-thumbnail wp-image-203" /><br />
The days where forms had to be boring are definitely over. Instead, forms can and should be part of the overall design. </p>
<p>We are not designers, we just like pretty things (and pretty code). And we like it best if it all is functional and adds to the experience without limiting it. And while we do use jQuery for certain effects on other sites, these a pure CSS solutions.<br />
<span id="more-201"></span><br />
Everything described here we are using in the comments form at the bottom of this page.</p>
<div style='clear:both'></div>
<h3>1) Dress up your Submit button (<em>without using input type=&quot;image&quot;</em>): The easiest way ever</h3>
<p>What you need:<br />
a) an image sprite<br />
b) a class/id to identify your submit button<br />
c) the pseudo-class :hover</p>
<p>We are using a sprite (an image containing our button&#8217;s two *states*) to avoid loading another image (plus we promised not to use any JavaScript); we are simply shifting the visible part of the image when :hover is called (the user moves the mouse over the button).</p>
<p>We are using a blank sprite (without any text); this way we can simply assign what we want to appear *on the button* to the button&#8217;s value in our HTML code instead of having to create a variety of different images. We are NOT using the <a href="http://www.alistapart.com/articles/slidingdoors//" target='bwin'>sliding doors technique</a> (first introduced in 2003) to create variable width buttons.</p>
<p>Our sprite is 150&#215;50 and will definitely accommodate the text *submit comment*:<br />
<a href='http://blog.ninanet.com/wp-includes/images/s_buttons5.png' rel="wp-prettyPhoto[g201]"><img alt="Submit sprite" src="http://blog.ninanet.com/wp-includes/images/s_buttons5.png" title="Submit sprite" class="alignnone" width="150" height="50" /></a></p>
<p>We create a submit button, and (we like it simple) add an id with the value *submit*. If you have more submit buttons on your site, create a class for them and automatically apply the definitions to all your submit buttons. Remember: an id must be unique to the page.</p>
<p>The HTML:</p>
<pre class='brush:html'>
<input type="submit" id="submit" value="submit comment" /></pre>
<p>We need some CSS:</p>
<pre class='brush:css'>
#submit {
	border:0;
	width:150px;
	height:25px;
	color:#111111;
	font-size:11px;
	background:url("path-to-the-image-file") no-repeat 0 0;
}
</pre>
<p>What is happening here?<br />
1: Add a selector for the previously assigned id &#8220;submit&#8221; (#submit).<br />
2: Set the border to 0. Otherwise, your browser will display the default border around the element.<br />
3: Set the width of the button (150px &#8211; same width as the sprite)<br />
4: Set the height of the button (50px &#8211; 50% of the sprite&#8217;s height)<br />
5: The color for the foreground font (the color you want the text on the button to be)<br />
6: The font size<br />
7: Shorthand background definitions:<br />
Path to the sprite (url)<br />
do not repeat the image<br />
start displaying the image starting at 0 px from the left and 0 px from the top (You can also use &#8220;top left&#8221; instead of 0 0).</p>
<p>In the :hover declaration for the id &#8220;submit&#8221; (#submit) we change the foreground color (the color for the text) and tell the browser to display a different part of the image: start at 0 px from the left (same as above) and 25 px from the top:</p>
<pre class='brush:css'>
#submit:hover {
	color:#a2eb41;
	background:url("path-to-the-image-file") no-repeat 0 -25px ;
}
</pre>
<div style='clear:both;height:15px'></div>
<p>Note/Disclaimer: While IE 6 will display the background image, it does not recognize Alpha transparency in PNG files. If you need to match the background-color of your element, create your sprite with a matching background.<br />
IE 6 also does NOT recognize the :hover pseudo-class. Font color and background image do not change in IE 6. IE 7 does recognize :hover, but still doesn&#8217;t recognize :focus (which we will use in the next part).</p>
<div style='clear:both;height:20px'></div>
<div style="margin-top:20px;">
	<!--<div style="float:left;margin-right:10px;"><fb:send href="http%3A%2F%2Fblog.ninanet.com%2F2010%2F03%2F22%2Fdress-up-your-forms1" font=""></fb:send></div>-->
	<div style="float:left"><div id="fb-root"></div><div id="facebook_like6"> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <fb:like href=http%3A%2F%2Fblog.ninanet.com%2F2010%2F03%2F22%2Fdress-up-your-forms1 show_faces="true" width="450" send="true"></fb:like></div></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.ninanet.com/2010/03/22/dress-up-your-forms1/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
