<?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>Templatix Blog &#187; Tricks</title>
	<atom:link href="http://blog.templatix.org/category/tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.templatix.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 20 Jun 2011 17:08:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>PNG transparency in IE5+ and FF</title>
		<link>http://blog.templatix.org/2009/08/png-transparency-in-ie5-and-ff/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=png-transparency-in-ie5-and-ff</link>
		<comments>http://blog.templatix.org/2009/08/png-transparency-in-ie5-and-ff/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 11:44:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=65</guid>
		<description><![CDATA[If you ever had to use GIFs and you know just how jaggedy that transparency around the edges is, the PNG format, with it&#8217;s smooth transparency levels, is purely God-send. it&#8217;s just that IE (5,6,7) is, as usual, so stupid, that it doesn&#8217;t know what to do with the transparent areas and simply puts them [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever had to use GIFs and you know just how jaggedy that transparency around the edges is, the PNG format, with it&#8217;s smooth transparency levels, is purely God-send. it&#8217;s just that IE (5,6,7) is, as usual, so stupid, that it doesn&#8217;t know what to do with the transparent areas and simply puts them over an abnoxious opaque gray rectangle. If you really must have PNG transparency into IE, you must use a dedicated filter (yet another M$ abomination), which filter in turn is able to display a transparent PNG as a background image, like so:</p>
<p><strong>filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=img/png-file.png);</strong></p>
<p>The most commonly used solution for the geek ones os to implement a javascript programmed to parse the whole shazan, to look for PNG references and, with a global replace, to turn those into filter areas. Since this is a javascript-dependent solution, and since it comes with alterations on the structure of the document, I&#8217;ll just drop it right here and move along to the really intersting part of the problem, which is the simpler CSS solution.</p>
<p>Why CSS? Well, simply because most ofthen than not, you need to use PNGs within an external CSS, and javascript stops there.</p>
<p><em>If you didn&#8217;t get a chance to read the <a href="http://graffiti.hbfx.com/?p=74" target="_blank">!important;</a> article, I strongly recommend you do so before moving along with this article.</em></p>
<p>Normally, in CSS, we set a background image like this:</p>
<p><strong><br />
.style {<br />
background-image: url(</strong><strong>img/png-file.png</strong><strong>);<br />
}</strong></p>
<p>, which works in any sane browser, but not in IE.<br />
In IE, as I was saying, you MUST do it like this:</p>
<p><strong><br />
.style {<br />
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=img/png-file.png);<br />
}</strong></p>
<p>As you can see, we have two different properties trying to accomplish the same thing. If you already read the above-recommended article, you&#8217;ll understand how the solution to this problem is to apply a double <em><strong>!important;</strong></em> , like this:</p>
<p><strong>.style {</strong></p>
<p><strong> </strong></p>
<p><strong>background-image: url(</strong><strong>img/png-file.png</strong><strong>) !important;<br />
</strong><strong> </strong></p>
<p><strong> </strong></p>
<p><strong>background-image: none</strong><strong>;</strong></p>
<p><strong> </strong></p>
<p><strong>filter: none !important;</strong></p>
<p><strong> </strong></p>
<p><strong>filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=img/png-file.png);</strong></p>
<p><strong> </strong></p>
<p><strong> }</strong></p>
<p>This way, FF will &#8220;see&#8221; one valid background and zero filters, while IE will &#8220;see&#8221; zero background and one filter. Problem solved. That&#8217;s it for today&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2009/08/png-transparency-in-ie5-and-ff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ABSOLUTE-positioned elements in RELATIVE context</title>
		<link>http://blog.templatix.org/2008/09/absolute-positioned-elements-in-relative-context/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=absolute-positioned-elements-in-relative-context</link>
		<comments>http://blog.templatix.org/2008/09/absolute-positioned-elements-in-relative-context/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 06:43:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=52</guid>
		<description><![CDATA[Sometimes, as in the case of the graphically rich yet still editable buttons, you may need to use elements positioned ABSOLUTE in a context positioned RELATIVE. We&#8217;re talking about the &#8220;position&#8221; CSS property, that can take one of 4 possible values: absolute / relative / fixed / static. I&#8217;ll leave aside fixed and static for now, and [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, as in the case of the <a title="graphically rich yet still editable buttons" href="http://blog.templatix.org/2008/09/graphically-rich-yet-still-editable-buttons-andor-tabs-optimised-and-now-with-roll-over/" target="_blank">graphically rich yet still editable buttons</a>, you may need to use elements positioned ABSOLUTE in a context positioned RELATIVE.<br />
We&#8217;re talking about the &#8220;<strong>position</strong>&#8221; CSS property, that can take one of 4 possible values: <strong>absolute </strong>/ <strong>relative </strong>/ <strong>fixed</strong> / <strong>static</strong>. I&#8217;ll leave aside <strong>fixed</strong> and <strong>static</strong> for now, and I&#8217;ll focus instead on those that interest us here: <strong>relative</strong> si <strong>absolute</strong>.</p>
<p><strong><img id="image72" src="http://blog.templatix.org/wp-content/uploads/2007/02/tutorial-2.gif" border="0" alt="tutorial-2.gif" hspace="5" align="left" /></strong><em>In this image I&#8217;m using as an example, the blue border represents the parent element (the context), the red border is an element positioned absolute, and the green border represents an element positioned relative. The red and green elements are included, code-wise, in the blue one, obiously.<br />
</em><br />
<strong>Relative</strong> &#8211; using the <strong>position: relative;</strong> CSS property, we instruct the browser to position the element relative to its context, <strong>in a fluid mode</strong>. In other words, we force the relative element to depend, position-wise, on it&#8217;s parent, but also on the in-line flow of the other elements present in the same context. Put bluntly, we force the element to behave like a letter in a block of text.<br />
<strong>Absolute </strong>- using the <strong>position: absolute;</strong> CSS property, we instruct the browser to position the element relative to its context, but <strong>independent</strong> of the in-line flow of the other elements in the context. In other words, we force the element to maintain fixed position coordinates, expressed in pixels or directions.</p>
<p><strong>At least in theory.</strong><span id="more-52"></span></p>
<p>Because, when you try to do this in real life, you notice that <strong>IE and FF go bananas</strong> when using position:absolute, every browser <strong>interpreting in its own way what element to report the positioning to</strong>. And the resulting effect <strong>will look</strong><strong> completely different in different browsers.</strong></p>
<p>Why is that? Because browsers decide differently on wheather the next relative parent is either the next logical parent or the BODY.</p>
<p>Sounds absurd, I know, but all makes sense in the end, you&#8217;ll see. When they need to position an element = ABSOLUTE, all browsers start looking up, ierarchically, looking for the next HTML element defined specifically as RELATIVE. Some consider this to be the <strong>parent</strong>, some consider the <strong>body. Hence the difference in visual results.</strong></p>
<p><strong>The solution? <img src='http://blog.templatix.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  very simple</strong>: (Even if it sounds redundant,) when you tant to position <strong>X absolute in </strong><strong>Y</strong>, then specifically define <strong>Y</strong> as having a <strong>position: relative;</strong>.</p>
<p>This will force ANY browser to explicitely understand what tag to report to (remember? the next ierarchically superior element that is explicitely set as <strong>relative</strong>), and to visually solve the problem in the same way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2008/09/absolute-positioned-elements-in-relative-context/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Horisontally centered DIVs: look out for MARGINs!</title>
		<link>http://blog.templatix.org/2008/09/horisontally-centered-divs-look-out-for-margins/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=horisontally-centered-divs-look-out-for-margins</link>
		<comments>http://blog.templatix.org/2008/09/horisontally-centered-divs-look-out-for-margins/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 22:37:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=46</guid>
		<description><![CDATA[I googled this shit till I saw green&#8230; Why? Because I wanted to get a simple thing: a DIV horisontally centered in the page. IE, simple and retarded as it is, worked. FF instead, with it&#8217;s purist pretentious flavour, refused. That is, until I found out why. Saner browsers (FF included) don&#8217;t take things &#8220;for [...]]]></description>
			<content:encoded><![CDATA[<p>I googled this shit till I saw green&#8230; Why? Because I wanted to get a simple thing: a DIV horisontally centered in the page. IE, simple and retarded as it is, worked. FF instead, with it&#8217;s purist pretentious flavour, refused. That is, until I found out why.</p>
<p>Saner browsers (FF included) don&#8217;t take things &#8220;for granted&#8221;. They don&#8217;t work user-friendly, but mathematically. To position an element in relative terms, <b>the browser needs to know exactly what are the parameters needed for the calculation of that particular relative position</b>. Since, in this case, we&#8217;re talking horisontal positioning, the browser needs to know the div&#8217;s horisontal margins (left and right). In other words, if I want a DIV to be horisontally centered, I MUST tell it to have:</p>
<p><b>margin-left: auto;<br />
margin-right: auto;</b></p>
<p>Without these simple settings, FF would stubbornly position any non-floating div to the left margin of it&#8217;s holder/parent, irrespective of that holder/parent&#8217;s text-align.</p>
<p>All said and done, the problem is solved. Too easy? Doesn&#8217;t matter, what matters is that it helps you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2008/09/horisontally-centered-divs-look-out-for-margins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DIV vertically centered in the page &#8211; no tables</title>
		<link>http://blog.templatix.org/2008/09/div-centered-in-the-page-no-tables/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=div-centered-in-the-page-no-tables</link>
		<comments>http://blog.templatix.org/2008/09/div-centered-in-the-page-no-tables/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 22:27:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tricks]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=44</guid>
		<description><![CDATA[Back in the day, when TABLES ruled the world, getting a layout compleely centered in the page was relatively easy: you&#8217;d just insert a one-cell table, align that table to the center both horisontally and vertically, and then you&#8217;d insert yet anothr table in that cell. That was it, plain and simple. But this would [...]]]></description>
			<content:encoded><![CDATA[<p>Back in the day, when TABLES ruled the world, getting a layout compleely centered in the page was relatively easy: you&#8217;d just insert a one-cell table, align that table to the center both horisontally and vertically, and then you&#8217;d insert yet anothr table in that cell. That was it, plain and simple. But this would never work in NS, for the simple reason that NS would only observe the first table&#8217;s height &#8211; the rest of the tables&#8217; heights being totally disregarded. Well, that was back in the day, when not only did people know what NS was (Netscape, for younger kids), but NS was the buzz-word of the day and everybody used it. Not anymore.</p>
<p>But the problem stays. Why? Because verical-aligning is only specific to certain HTML elements, and DIV isn&#8217;t one of them. So what then?</p>
<p>Well&#8230; it depends. You have not one, but two solutions, depending wheather you want your DIV to have a fixed height, or you want it to have a height relative to the height of the page. In either case, the basic principle is that your DIV must be placed into a context clearly defined position-wise, be it relative or absolute. Let&#8217;s take them one at a time&#8230;</p>
<p> </p>
<hr /><em><strong>1. Vertically centered DIV with the height relative to the height of the page.</strong></em>&#8230;</p>
<p>Simple <img src='http://blog.templatix.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  You set the din in the CSS, with the following parameters:</p>
<p><strong>position: absolute; height: x%; top: ((100-x)/2)%;</strong></p>
<p align="center"><img src="http://blog.templatix.org/wp-content/uploads/2007/02/tutorial-3.gif" alt="tutorial-3.gif" /></p>
<p>Well, what I just wrote is an EXAMPLE, not to be taken literally, but to be interpreted. Don&#8217;t just copy-paste, cuz it won&#8217;t work. See it &#8220;translated&#8221; into usable code, in this example:</p>
<p><strong>position: absolute; height: 40%; top: 30%;</strong></p>
<p>If you have any questions, please leave a comment and we&#8217;ll sort them out</p>
<p><span id="more-44"></span></p>
<hr /><em><strong>1. Vertically centered DIV with fixed height.</strong></em></p>
<p>This one may look trickyer&#8230; but it&#8217;s doable. Before anything, let&#8217;s create a &#8220;dummy&#8221; div, and define it like so::</p>
<p><strong>.dummy {position: absolute; top: 50%;}</strong></p>
<p>Clearly, this div will sit exactly in the vertical middle of the page. Step 2 is to create, inside this dummy div, the div that we really care about. Let&#8217;s say it will have the height &#8220;X&#8221;. The CSS parameters will look like this:</p>
<p><strong>position: absolute; height: Xpx; top: (-X/2)px; </strong></p>
<p align="center"><img src="http://blog.templatix.org/wp-content/uploads/2007/02/tutorial-4.gif" alt="tutorial-4.gif" /></p>
<p>Again, this is just an example of a formula. Translated in a real-life example, it would look something like this:</p>
<p><strong>position: absolute; height: 300px; top: -150px; </strong></p>
<p>Problem solved!</p>
<p><em><strong>Note 1:</strong> For whoever doesn&#8217;t quite grasp yet what&#8217;s going on with position:absolute and what it involves, I strongly recommend the post <a title="Absolute-positioned elements in relative context" href="http://blog.templatix.org/2008/09/absolute-positioned-elements-in-relative-context/" target="_blank">Elements positioned ABSOLUTE in a RELATIVE context</a>.<br />
<strong>Note 2:</strong> For who has problems with horisontal alignment or with widths, read this: <a href="http://blog.templatix.org/2008/09/horisontally-centered-divs-look-out-for-margins/">Horisontally centered DIVs: look out for MARGINs!</a>.<br />
<strong>Final Note:</strong> The parameters given in the examples above represent a bare minimum necessary for the functioning of these examples. You&#8217;re, obviously, free to add up as many extra parameters as you see fit, starting with the common width and going up the ladder to the baddest meanest hacks you know.  <img src='http://blog.templatix.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2008/09/div-centered-in-the-page-no-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>1px table border</title>
		<link>http://blog.templatix.org/2008/09/1px-table-border/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=1px-table-border</link>
		<comments>http://blog.templatix.org/2008/09/1px-table-border/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 21:02:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=37</guid>
		<description><![CDATA[Here&#8217;s an older, html trick, from the days when CSS was just a dream&#8230; If you ever tried to get an 1px; border on a table, in HTML, you probably wrote this: &#60; table border = &#8221; 1 &#8221; bordercolor = &#8221; #000000 &#8221; &#62; etc. But see it in a browser and it&#8217;ll show [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an older, html trick, from the days when CSS was just a dream&#8230;</p>
<p>If you ever tried to get an 1px; border on a table, in HTML, you probably wrote this: &lt; table border = &#8221; 1 &#8221;  bordercolor = &#8221; #000000 &#8221; &gt; etc. But see it in a browser and it&#8217;ll show 2px borders instead. WHY? Simple, if you come to think about it: because, when defining the 1px border, it applies to both the table and it&#8217;s cells (by means of inheritance), and the 2 borders adding up always result in disurbing, thick, 2px borders. To better understand how this happens, suffice it to give the table acellspacing=&#8221;5&#8243; &#8211; only then will you see how, in fact, the border was 1px thick&#8230; The 2 cases look like this:</p>
<p><img src="http://graffiti.hbfx.com/wp-content/uploads/2007/02/tutorial-7.gif" alt="tutorial-7.gif" /></p>
<p>Still, what to do, if CSS isn&#8217;t at hand and you still want that fine 1px border? Use this little trick:</p>
<p>&lt; table cellspacing = &#8221; 1 &#8221; bgcolor = &#8221; #000000 &#8221; &gt; &#8230; and then give all the cells a white background-color. This way, with no table-border but with an 1px spacing, the spacing WILL BECOME the 1px border you wanted in the first place.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2008/09/1px-table-border/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Border around empty table cells</title>
		<link>http://blog.templatix.org/2008/09/border-around-empty-table-cells/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=border-around-empty-table-cells</link>
		<comments>http://blog.templatix.org/2008/09/border-around-empty-table-cells/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 19:57:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=32</guid>
		<description><![CDATA[It happens often, when working with tables, to &#8220;forget&#8221; empty cells, i.e. cells without any content at all within, not with even as much as a shy &#38; nbsp ;. That makes them look awkward in the browser (awkward = borderless) and,most of all, to look like coding errors, which coulod become unpleasant. For those [...]]]></description>
			<content:encoded><![CDATA[<p>It happens often, when working with tables, to &#8220;forget&#8221; empty cells, i.e. cells without any content at all within, not with even as much as a shy &amp; nbsp ;. That makes them look awkward in the browser (awkward = borderless) and,most of all, to look like coding errors, which coulod become unpleasant. For those lacking the patience to fiddle again the whole html code, there&#8217;s a solution: to define the following property in the CSS code:</p>
<pre>{ empty-cells: show }</pre>
<p>This will force all the empty cells to SHOW the border, even if empty. (the other possible values for this property are: <em><strong>hide</strong></em> and <em><strong>inherit</strong></em>)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2008/09/border-around-empty-table-cells/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>min-height, min-width in all browsers</title>
		<link>http://blog.templatix.org/2008/09/min-height-min-width-in-all-browsers/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=min-height-min-width-in-all-browsers</link>
		<comments>http://blog.templatix.org/2008/09/min-height-min-width-in-all-browsers/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 18:44:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tricks]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=11</guid>
		<description><![CDATA[I wrote, some time ago, about how to solve this problem with min or max dimensions in more retarder browsers. The solution proposed was to use conditional javascript expressions inside the CSS file. Not very elegant, and quite limited. Meanwhile I found a much simpler, more elegant and better validating solution. Let&#8217;s say we want [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote, some time ago, about how to solve this <a href="http://graffiti.hbfx.com/?p=75">problem with min or max dimensions in more retarder browsers</a>.</p>
<p>The solution proposed was to use conditional javascript expressions inside the CSS file. Not very elegant, and quite limited.</p>
<p>Meanwhile I found a much simpler, more elegant and better validating solution. Let&#8217;s say we want to get a min-height of 400px. How do we go about it? Easy enough, we use 3 CSS properties instead of just one, like so::</p>
<pre>min-height: 400px;
height: 400px;
height: auto !important;</pre>
<p>And, miracle! It works! In every browser that I always test against: IE6, IE7, FF, Opera, Safari. Enjoy&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2008/09/min-height-min-width-in-all-browsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

