<?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>ozblog &#187; CSS tips &amp; trick</title>
	<atom:link href="http://ozblog.com.au/category/css-tips-trick/feed/" rel="self" type="application/rss+xml" />
	<link>http://ozblog.com.au</link>
	<description>If your vocation is your vacation you&#039;ll never work a day in your life</description>
	<lastBuildDate>Tue, 06 Dec 2011 00:36:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Detect iPhones, iPods and other mobile devices</title>
		<link>http://ozblog.com.au/2011/07/25/detect-iphones-ipods-and-other-mobile-devices/</link>
		<comments>http://ozblog.com.au/2011/07/25/detect-iphones-ipods-and-other-mobile-devices/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 20:24:09 +0000</pubDate>
		<dc:creator>Levi Putna</dc:creator>
				<category><![CDATA[CSS tips & trick]]></category>
		<category><![CDATA[Mobile Web App]]></category>
		<category><![CDATA[Web Design and Trends]]></category>

		<guid isPermaLink="false">http://ozblog.com.au/?p=489</guid>
		<description><![CDATA[Introduction When developing for the iPhone, iPad, iPod Touch and other mobile devices, the first thing we have to do is obviously detect it, so we can apply specific code or styles to it. The following code snippets will detect [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>When developing for the iPhone, iPad, iPod Touch and other mobile devices, the first thing we have to do is obviously detect it, so we can apply specific code or styles to it. The following code snippets will detect iPhones and iPods using various methods, depending on your situation you can use one or a combination of these methods. </p>
<h2>JavaScript</h2>
<p>Whether your developing a web application or just making a iPhone compatible version of your website it can be very beneficial to target specific JavaScript to help create a rich interactive UI.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">userAgent</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/iPhone/i</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">userAgent</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/iPod/i</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">userAgent</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/iPad/i</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Mobile Website'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>PHP</h2>
<p>For security reasons you may prefer to use PHP in order to detect iPhones, iPad and iPods touch on the server side.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'iPhone'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'iPod'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'iPad'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Mobile Website&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>CSS</h2>
<p>Browser sniffing can be useful, but for many reasons it isn’t the best practice to detect a browser as there are many types of mobile device out there and you don&#8217;t want to have to target your code at every specific device. My preferred option is to target css to a device with and orientation with css, this can make design complicated as you have to think about how your layout will adjust however </p>
<p>If you’re looking for a cleaner way to apply CSS styles to the iPhone or small mobile devices only, you should use the following.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media screen and (max-device-width: 480px){</span>
    <span style="color: #808080; font-style: italic;">/* iPhone specific CSS goes here */</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>You can extend this technique to build a css file that adjusts for specifics width of device.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media only screen and (device-width: 768px) {</span>
  <span style="color: #808080; font-style: italic;">/* For general iPad layouts */</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>Device Orientation</h2>
<p>You can even build css for device orientation. This example will draw the menu on the left when in landscape and on the bottom when in portrat.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {</span>
  <span style="color: #808080; font-style: italic;">/* For portrait layouts only */</span>
	<span style="color: #cc00cc;">#menu</span> <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #cc00cc;">#body</span> <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {</span>
  <span style="color: #808080; font-style: italic;">/* For landscape layouts only */</span>
&nbsp;
<span style="color: #cc00cc;">#menu</span> <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">30%</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">float</span> <span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #cc00cc;">#body</span> <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">70%</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">float</span> <span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>iPhone Images</h2>
<p>Most website images are above 500 pixels wide. Due to the iPhone small size, there’s a strong chance that images will break out of the view aria. I recommend automatically re-size all website images to max 100% device width.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media screen and (max-device-width: 480px){</span>
    img<span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">max-width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>Defining a Viewport</h2>
<p>The width=device-width statement allows you to define the document width as being the same than the width of the iPhone or mobile device screen.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&lt;meta name<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;width=device-width; initial-scale=1.0; maximum-scale=1.0;&quot;</span><span style="color: #00AA00;">&gt;</span></pre></div></div>

<h2>Font Size</h2>
<p>When you change device orientation, Safari and some other mobile browsers adjust the font size. If you’d like to prevent this effect, simply use the following CSS declaration.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">html<span style="color: #00AA00;">,</span> body<span style="color: #00AA00;">,</span> form<span style="color: #00AA00;">,</span> fieldset<span style="color: #00AA00;">,</span> p<span style="color: #00AA00;">,</span> div<span style="color: #00AA00;">,</span> h1<span style="color: #00AA00;">,</span> h2<span style="color: #00AA00;">,</span> h3<span style="color: #00AA00;">,</span> h4<span style="color: #00AA00;">,</span> h5<span style="color: #00AA00;">,</span> h6 <span style="color: #00AA00;">&#123;</span>
    -webkit-text-size-adjust<span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>Special Links</h2>
<p>Finally do you remember those “mailto” link that were very popular some years ago? This prefix automatically open the default email client used by the person who clicked on it. The iPhone has introduced two similar prefixes, tel and sms, which allows the person who clicked on it to phone or text automatically.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>a href=<span style="color: #483d8b;">&quot;tel:12345678900&quot;</span><span style="color: #66cc66;">&gt;</span>Call me<span style="color: #66cc66;">&lt;</span>/a<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>a href=<span style="color: #483d8b;">&quot;sms:12345678900&quot;</span><span style="color: #66cc66;">&gt;</span>Send me a text<span style="color: #66cc66;">&lt;</span>/a<span style="color: #66cc66;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ozblog.com.au/2011/07/25/detect-iphones-ipods-and-other-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE Fix Bicubic Scaling for Images</title>
		<link>http://ozblog.com.au/2009/04/01/ie-fix-bicubic-scaling-for-images/</link>
		<comments>http://ozblog.com.au/2009/04/01/ie-fix-bicubic-scaling-for-images/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 11:49:48 +0000</pubDate>
		<dc:creator>Levi Putna</dc:creator>
				<category><![CDATA[CSS tips & trick]]></category>

		<guid isPermaLink="false">http://ozblog.com.au/?p=322</guid>
		<description><![CDATA[If you use width or height tags to resize images in your markup, IE will ensure they look incredibly awful unless you use this little snippet. In general, resizing images in the browser isn’t recommended, but of course there are [...]]]></description>
			<content:encoded><![CDATA[<p>If you use <tt>width</tt> or <tt>height</tt> tags to resize images in your markup, IE will ensure they look incredibly awful unless you use this little snippet. In general, resizing images in the browser isn’t recommended, but of course there are always exceptions.</p>
<p>And here it is:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">img <span style="color: #00AA00;">&#123;</span> -ms-interpolation-mode<span style="color: #00AA00;">:</span> bicubic<span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ozblog.com.au/2009/04/01/ie-fix-bicubic-scaling-for-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>!important ignored by IE</title>
		<link>http://ozblog.com.au/2009/01/26/important-ignored-by-ie/</link>
		<comments>http://ozblog.com.au/2009/01/26/important-ignored-by-ie/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 23:03:18 +0000</pubDate>
		<dc:creator>Levi Putna</dc:creator>
				<category><![CDATA[CSS tips & trick]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[margins]]></category>
		<category><![CDATA[precedence]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://ozblog.com.au/?p=279</guid>
		<description><![CDATA[Normally in CSS whichever rule is specified last takes precedence. However if you use !important after a command then this CSS command will take precedence regardless of what appears after it. This is true for all browsers except IE. An [...]]]></description>
			<content:encoded><![CDATA[<p>Normally in CSS whichever rule is specified last takes precedence. However if you <strong>use <code>!important</code> after a command then this CSS command will take precedence</strong> regardless of what appears after it. This is true for all browsers except IE. An example of this would be:</p>
<p><code>margin-top: 3.5em !important; margin-top: 2em</code></p>
<p>So, the top margin will be set to 3.5em for all browsers except IE, which will have a top margin of 2em. This can sometimes come in useful, especially when using relative margins (such as in this example) as these can display slightly differently between IE and other browsers.</p>
]]></content:encoded>
			<wfw:commentRss>http://ozblog.com.au/2009/01/26/important-ignored-by-ie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two classes together</title>
		<link>http://ozblog.com.au/2009/01/24/two-classes-together/</link>
		<comments>http://ozblog.com.au/2009/01/24/two-classes-together/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 23:03:17 +0000</pubDate>
		<dc:creator>Levi Putna</dc:creator>
				<category><![CDATA[CSS tips & trick]]></category>
		<category><![CDATA[attributes]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css document]]></category>
		<category><![CDATA[paragraph]]></category>

		<guid isPermaLink="false">http://ozblog.com.au/?p=277</guid>
		<description><![CDATA[Usually attributes are assigned just one class, but this doesn&#8217;t mean that that&#8217;s all you&#8217;re allowed. In reality, you can assign as many classes as you like! For example: &#60;p class="text side"&#62; Some Text &#60;/p&#62; Using these two classes together [...]]]></description>
			<content:encoded><![CDATA[<p>Usually attributes are assigned just one class, but this doesn&#8217;t mean that that&#8217;s all you&#8217;re allowed. In reality, you can assign as many classes as you like! For example:</p>
<p><code>&lt;p class="text side"&gt; Some Text &lt;/p&gt;<br />
</code></p>
<p>Using these two classes together (separated by a space, not with a comma) means that the paragraph calls up the rules assigned to both text and side. If any rules overlap between the two classes then the class which is below the other in the CSS document will take precedence.</p>
]]></content:encoded>
			<wfw:commentRss>http://ozblog.com.au/2009/01/24/two-classes-together/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE Min-Height Hack</title>
		<link>http://ozblog.com.au/2008/10/24/ie-min-height-hack/</link>
		<comments>http://ozblog.com.au/2008/10/24/ie-min-height-hack/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 07:07:34 +0000</pubDate>
		<dc:creator>Levi Putna</dc:creator>
				<category><![CDATA[CSS tips & trick]]></category>
		<category><![CDATA[Web Design and Trends]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[height]]></category>
		<category><![CDATA[internet explorer 5]]></category>
		<category><![CDATA[min-height]]></category>
		<category><![CDATA[standards compliant browsers]]></category>

		<guid isPermaLink="false">http://ozblog.mmow.biz/?p=213</guid>
		<description><![CDATA[It is often nice to have your webpage span the full height of the window even if you only have a small amount of content displaying at the top.]]></description>
			<content:encoded><![CDATA[<h4>Introduction</h4>
<p>It is often nice to have your webpage span the full height of the window even if you only have a small amount of content displaying at the top.</p>
<table border="0">
<tbody>
<tr>
<td><a href="http://ozblog.com.au/files/2008/10/css-min-height2.jpg"><img class="alignnone size-medium wp-image-229" src="http://ozblog.com.au/files/2008/10/css-min-height2.jpg" alt="" width="250" /></a></td>
<td><a href="http://ozblog.com.au/files/2008/10/css-min-height1.jpg"><img class="alignnone size-medium wp-image-228" src="http://ozblog.com.au/files/2008/10/css-min-height1.jpg" alt="" width="250" /></a></td>
</tr>
<tr>
<td><em>With min-height hack<br />
</em></td>
<td><em>Without min-height hack<br />
</em></td>
</tr>
</tbody>
</table>
<h4>The Problem</h4>
<p>This is easy in standards compliant browsers like Firefox with the CSS min-height property. However IE (Internet Explorer) 5 and 6 doesn’t understand the min-height property.</p>
<p>Although IE doesn’t understand the min-height it will treat height almost as though it were min-height and will expand an element that contains its content even though the height has been set.</p>
<p>Standards compliant browsers on the other hand will not expand an element past the set height. So height cannot be used as min-height.</p>
<p>Defining both height and min-height in the same element won’t work because height will override the Min-height in standards compliant browsers.</p>
<h4>The Solution</h4>
<p>That’s when I came across this nifty little hack. Thanks <a href="http://www.dustindiaz.com/min-height-fast-hack/">http://www.dustindiaz.com/min-height-fast-hack/</a></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">selector <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span> !important<span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h4>The Explanation</h4>
<p>So how dose it work? Let’s break it down.</p>
<p><strong>height:</strong></p>
<ul>
<li>In standards compliant browsers height is a fixed height, non expanding “not more not less”</li>
<li>In IE height will set a fixed minimum height but will expand with the element if it exceeds the set height.</li>
</ul>
<p><strong>min-height:</strong></p>
<ul>
<li>In standards compliant browsers min-height is, a fixed minimum height. “I want it to be at least this height” and will expand with the element simpler to height in IE.</li>
<li>IE doesn’t support the min-height property.</li>
</ul>
<p><strong>!important</strong></p>
<ul>
<li>An !important declaration can be likened to an override. It allows you to declare an overriding property, which will be considered taking precedence even if there are other rules with the same specificity declaring.</li>
<li>IE6 ignores !important.</li>
</ul>
<p><strong>height: auto !important;<br />
</strong><br />
Let the actual final height auto-adjust (while obeying the declared min-height, of course). Even though auto is the default for any element&#8217;s height, we want to declare it because of the following rule.</p>
<p>So standards compliant browsers will see:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span></pre></div></div>

<p>IE6, on the other hand, due to ignoring !important and not understanding min-height, will see:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span><span style="color: #00AA00;">;</span></pre></div></div>

<p>And there you go min-height that works in all modern browsers.</p>
]]></content:encoded>
			<wfw:commentRss>http://ozblog.com.au/2008/10/24/ie-min-height-hack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

