<?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; CSS</title>
	<atom:link href="http://blog.templatix.org/category/css/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>!important;</title>
		<link>http://blog.templatix.org/2008/09/important/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=important</link>
		<comments>http://blog.templatix.org/2008/09/important/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 06:05:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=49</guid>
		<description><![CDATA[If you didn&#8217;t know it yet, there&#8217;s a little CSS &#8220;hack&#8221; that, properly used, not only passes all classic validation systems, but is also very useful. We&#8217;re talking about !important;. Basic usage: instead of width: 300px; you can write width: 300px !important;. But, more important, what does it do? Let&#8217;s see&#8230; The basic function of [...]]]></description>
			<content:encoded><![CDATA[<p>If you didn&#8217;t know it yet, there&#8217;s a little CSS &#8220;hack&#8221; that, properly used, not only passes all classic validation systems, but is also very useful. We&#8217;re talking about <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#important-rules" target="_blank"><strong>!important;</strong></a>.</p>
<p>Basic usage: instead of <strong>width: 300px;</strong> you can write <strong>width: 300px !important;</strong>. But, more important, what does it do? Let&#8217;s see&#8230;</p>
<p>The basic function of !important; is to priorotize/set an ierarchy among the CSS properties attached to a page (be those inline or linked in external css files). In this respect, it can be used for 2 main purposes: <span id="more-49"></span></p>
<p><strong>1. </strong>The first purpose, more known, is to differentiate certain properties between <strong>FF and IE</strong>. In this instance, the hack relies on the fact that, in the cases where IE finds 2 definitions of the same property, it tends to prefer the property that doesn&#8217;t have the !important; attached to it.</p>
<p>Example:<br />
Let&#8217;s say we want an element to have in IE width: 100px; and in FF 120px; How do we achieve this? Easy: we write the same property twice: <strong>width: 120px !important; width: 100px;</strong>. FF will understand from this 120px, and IE will understand 100px. Easy, to the point and in many cases very useful.</p>
<p><strong>2. </strong>The second, less known but just as important function, it to <strong>prioritize ierarchically a css property</strong>. What does this mean?</p>
<p><em><strong>A.</strong></em> You may know (or just find out, now) that in CSS you can define CLASSES ot TAGs. The classes are particular cases and are prefixed with a dot, and the tags are global re-definitions of the way HTML tags should display. <strong>body {}</strong> redefines a TAG, and <strong>.body {}</strong> is a CLASS.</p>
<p>What&#8217;s important here is that a TAG&#8217;s properties are superior, ierarchically, to those of a CLASS. If, for instance, I define <strong>p {color: #cccccc;}</strong> and then, in a particular P, I want to use the class <strong>.green {color: #009900;}</strong>, <strong>.green will show up gray, instead of green</strong>, because a <strong>tag</strong> is more general/powerful than a <strong>class</strong>, i.e. <strong>P is more general/powerful than .green</strong>.<br />
<em><strong><br />
B.</strong></em> You may also know (or just find out) that in CSS we can define complex classes. For instance, <strong>.green {}</strong> is one thing, while <strong>.green .title {}</strong> means &#8220;all the <strong>title</strong>s found in a <strong>green</strong>&#8220;. This can help us structure, detail and prioritize very well and in an orderly fashion alot of classes and particular cases.</p>
<p>Getting back to our sheep: the bottomline from paragraphs <em><strong>A</strong></em> and <em><strong>B</strong></em> is that in CSS ierarchy exists and is important.<br />
But what do you do when you need to override that ierarchy? YOU USE <strong>!important;</strong>.</p>
<p>This way, the problem above (the one with p and .green) can be solved like this: <strong>.green {color: #009900 !important;}</strong>. This way, if we use a <strong>.green</strong> in a <strong>p</strong>, the color property in  .green will decome more important/powerful than the one in the p, and display correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2008/09/important/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>CLEARFIX &#8211; problem and solution for FF and IE (incluing IE7)</title>
		<link>http://blog.templatix.org/2008/09/clearfix-problem-and-solution-for-ff-and-ie-incluing-ie7/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=clearfix-problem-and-solution-for-ff-and-ie-incluing-ie7</link>
		<comments>http://blog.templatix.org/2008/09/clearfix-problem-and-solution-for-ff-and-ie-incluing-ie7/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 21:36:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=42</guid>
		<description><![CDATA[When working with DIV-s (as I&#8217;ve been doing, for a while now), if you want a layout going down as long as its contend goes, you&#8217;re forced to work with FLOAT-s. That is, with DIV-s that are positioned RELATIVE and that have a float:left or a float:right set up on them. The Problem The problem [...]]]></description>
			<content:encoded><![CDATA[<p>When working with DIV-s (as I&#8217;ve been doing, for a while now), if you want a layout going down as long as its contend goes, you&#8217;re forced to work with <strong>FLOAT</strong>-s. That is, with DIV-s that are positioned RELATIVE and that have a <strong>float:left</strong> or a <strong>float:right</strong> set up on them.</p>
<p><strong>The Problem</strong><br />
The problem is that the FLOAT&#8217;s visual rendering model is an archaic one, dating back when a float was limited to an &lt;IMG&gt;&#8217;s <strong>align: left</strong> / <strong>align: right</strong>, which allowed the text to flow around an image (or an image to &#8220;text-wrap&#8221;). Back in the day, a float was limited, conceptually, to &lt; IMG &gt; si &lt; P &gt;. What resulted from the old model? Something like this:</p>
<p><img src="http://blog.templatix.org/wp-content/uploads/2007/02/tutorial-5.gif" alt="tutorial-5.gif" /></p>
<p>If you look closer, you&#8217;ll see that the image included in the first &lt; P &gt; (marked with magenta in the image) has an align=&#8221;left&#8221; (the functional equivalent of <strong>float: left;</strong> in CSS), which makes the  &lt; P &gt;-s (including the ones to follow) to seamlessly flow around the image. All nice an dandy.</p>
<p>But what do you do when you want that image/float to &#8220;force&#8221; the height of it&#8217;s containing holder? What do you do if you want that &lt; P &gt; -ul containing the image to stretch down in a way to include ALL the image? That was easy peasy with tables, but DIVs make it much harder.<span id="more-42"></span></p>
<p>Why? Because, as I was saying: when they conceived and created the specification for the FLOAT model, the dear W3C guys simply considered the above model to be more natural. Don&#8217;t ask why. What this means, for the coder? A big&#8217;ol pain in the neck, because not only is it a serious issue, but it happens to be a cross-browser one too&#8230;</p>
<p><strong>The Solution?</strong></p>
<p>Various tests yielded various solutions for various browsers.</p>
<p>For instance, <strong>in IE</strong>, setting a <strong>height</strong> of the DIV was enough. And, in order not to affect the layout, it was best to just set the height to 1% &#8211; IE would spread its div-s as needed, anyway, moving through that 1% like mice through cheeze.</p>
<p>But this would wreck a layout <strong>in FF</strong> &#8211; since it had no effect whatsoever. In return, in FF it was enough to manually enter, at the end of the div, an HTML element with the <strong>clear:both</strong> property. This would force the DIV to stretch beyond that little forcepsed-in element, since clear-both allows no other elements to be in the same line with it, thus forcing the div to stretch below it. To better understand this, here&#8217;s another drawing:<br />
<img src="http://blog.templatix.org/wp-content/uploads/2007/02/tutorial-6.gif" alt="tutorial-6.gif" /></p>
<p>(that blue border around that dot illustrates the effect of <strong>clear-both;</strong>)</p>
<p>But since manually inserting code into the HTML just to get this working is rather un-elegant, they came up with another solution: to take advantage of a FF-specific CSS property: <strong>content: &#8220;&#8221;;</strong>. What this does, is it allows you to insert code into the HTML, from the CSS. Obviously, it only works in FF, but it&#8217;s useful in it&#8217;s way.</p>
<p>How can we apply these 2 solutions so far?</p>
<p><strong>FF:</strong></p>
<pre>.clearfix:after {content: "."; display: block; height: 0;
                 clear: both; visibility: hidden;}</pre>
<p><strong>IE:</strong></p>
<pre>* html .clearfix {height: 1%;}</pre>
<p>After which, in HTML, we give our DIV the class &#8220;clearfix&#8221;. And so we get to the famous &#8220;CLEARFIX&#8221; solution, which saved alot of HTML geeks from eternal shame:</p>
<pre>.clearfix:after  {content: "."; display: block; height: 0;
                  clear: both; visibility: hidden;}
/* Hides from IE-mac */
* html .clearfix {height: 1%;}
/* End hide from IE-mac */</pre>
<p>But wait! IE7 came along&#8230; And this trick didn&#8217;t work well with it&#8217;s majesty&#8230; What to do, what to do? Take all the sites you&#8217;ve done so far and start re-coding them just because IE7 is so retarded and clients who suddenly discover IE7 see theirs sites messed-up? This dear IE7 provided alot of meat in we-know-who&#8217;s mouth, fridge and family, especially since they had the nerve to announce that this would be the latest version, after which no more new CSS stuff to be implemented&#8230;</p>
<p>Just our luck (AGAIN) <a title="456bereastreet" href="http://www.456bereastreet.com/archive/200603/new_clearing_method_needed_for_ie7/" target="_blank">a bunck of good guys</a> humped the problem until thei made it squeak, and found a new solution; modify ONLY the CSS, and ONLY the CLEARFIX section, as follows:</p>
<pre>.clearfix:after {content:"."; display:block; height:0;
                 clear:both; visibility:hidden; }
.clearfix       {display:inline-block;}
/* Hide from IE Mac */
.clearfix       {display:block;}
/* End hide from IE Mac */</pre>
<p>Once redefined, this piece of CSS code made it all come back to normal, working in all browsers. Good job, guys, thank you for saving me from lots of senseless sweats!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2008/09/clearfix-problem-and-solution-for-ff-and-ie-incluing-ie7/feed/</wfw:commentRss>
		<slash:comments>2</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>:hover</title>
		<link>http://blog.templatix.org/2008/09/hover/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hover</link>
		<comments>http://blog.templatix.org/2008/09/hover/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 20:51:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=34</guid>
		<description><![CDATA[SIMPLY PUT: menu with submenus, CSS-only (no JS) Any modern browser (implicitely excluding all versions of IE), if is playing by the CSS book, has support for the dynamic pseudo-class &#8220;:hover&#8221; on ALL tags, not just on the lonely sad pathetic &#60; a &#62;. Note: As you may already know, in CSS there&#8217;s a series [...]]]></description>
			<content:encoded><![CDATA[<p><strong>SIMPLY PUT: menu with submenus, CSS-only (no JS)</strong></p>
<p>Any modern browser (implicitely excluding all versions of IE), if is playing by the CSS book, has support for the <a title="Dynamic Pseudo-classes  on W3C" href="http://www.w3.org/TR/CSS21/selector.html#dynamic-pseudo-classes" target="_blank">dynamic pseudo-class</a> &#8220;<strong>:hover</strong>&#8221; on ALL tags, not just on the lonely sad pathetic <strong>&lt; a &gt;</strong>.</p>
<blockquote><p>Note: As you may already know, in CSS there&#8217;s a series of dynamic pseudo-classes (:hover, :active si :focus) that traditionally get associated with &#8220;a&#8221; in order to create different styles for the 3 possible different states of a link, as in <strong>a:hover</strong>, for instance.</p></blockquote>
<p>Modern browsers, as I was saying, having implemented the support for this, allow for the association of the pseudo-classes with any HTML tag. In other words, you could very well define something like:</p>
<pre>td       {background-color: #cccccc;}
td:hover {background-color: #336699;}</pre>
<p>which would result in a background-color change on those td-s, on roll-over, without any need whatsoever to use HTML-bloating javascript code.</p>
<p><span id="more-34"></span>Pretty neat, huh? It&#8217;s an excellent feature, supported now even by the overly-and-yet-not-enough-booed IE7. Only the older IEs still go around butt-naked&#8230; So my recommendation is that you follow both the tutorial and the linked examples in a _modern_ browser.</p>
<p>Well, moving on with the tutorial, let&#8217;s see just what could we use this pretty thing for: Let&#8217;s imagine for a minute that we want to keep an HTML element hidden, making it visible only when we mouse-hover it&#8217;s parent. It&#8217;s an overly-known scenario for anybody who ever tried to build menus with sub-menus. To give you an example, I&#8217;ll just go back to a &lt; li &gt; case:</p>
<pre>&lt;ul id="menu"&gt;
  &lt;li&gt;&lt;a href="#"&gt;Element 1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#"&gt;Element 2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#"&gt;Element 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<p>This would be a classical, simple menu (I gave it an &#8220;id&#8221; for a simple reason: to be able to better controll the way in which to apply the CSSs later &#8211; in other words, if I have multiple ULs in the document and I want to restrict the behaviors to only THIS one, then I just restrict from the very begining how I apply the redefinition of the ULs and LIs in the CSS).</p>
<p>Let&#8217;s say we want to enrigh it a bit wit some second-level elements, by means of &#8211; yes, again &#8211; &lt; ul &gt; with &lt; li &gt; -s:</p>
<pre>&lt;ul id="menu"&gt;
  &lt;li&gt;&lt;a href="#"&gt;Element 1&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href="#"&gt;Sub-element 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#"&gt;Sub-element 2&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#"&gt;Sub-element 3&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href="#"&gt;Element 1&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href="#"&gt;Sub-element 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#"&gt;Sub-element 2&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#"&gt;Sub-element 3&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href="#"&gt;Element 1&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href="#"&gt;Sub-element 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#"&gt;Sub-element 2&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#"&gt;Sub-element 3&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;</pre>
<p>(You can check out what we&#8217;ve got so far, <a title=":hover - phase 1" href="http://blog.templatix.org/wp-content/uploads/2007/02/hover_1.html" target="_blank">here</a>).<br />
Let&#8217;s try and style it a bit, now! First of all I&#8217;ll want any &lt; ul &gt; found in the &lt; ul &gt; marked by the id=&#8221;menu&#8221; to be hidden:</p>
<pre>#menu ul {display: none;}</pre>
<blockquote><p>Note: Why use, for <strong>display</strong>, the value<strong>none</strong> and not <strong>hidden</strong>? Because any HTML element has two inherent properties: the <strong>visibility</strong> and the <strong>occupied space</strong>. While <strong>hidden</strong> only affects the visibility (like a sort of transparency: you can&#8217;t see the object, byt the space it occupied remains fermly on position), <strong>none</strong> affects both properties, both hiding the object and freeing up the space it occupied.</p></blockquote>
<p>Now that I&#8217;ve hidden the secondary menus, I want it to get back when I mouse-hover it&#8217;s containing &lt; li &gt;:</p>
<pre>li:hover ul {display: block;}</pre>
<p>(in other words: any <strong>UL</strong> found in a <strong>mouse-hovered LI</strong> will be displayed as a  <strong>block</strong>)<br />
As you can see <a title=":hover - phase 2" href="http://blog.templatix.org/wp-content/uploads/2007/02/hover_2.html" target="_blank">here</a>, we haven&#8217;t solved much, although logic tells you we should&#8217;ve.</p>
<blockquote><p>WHY: every CSS rule has a precise <a title="!important;" href="http://blog.templatix.org/2008/09/important/" target="_blank">importance</a>, that you can calculate simply by counting the elements that define it. And every element has in turn a predefined value, depending on what kind of element it is. A simple node (<strong>.my_class</strong> for instance) values <strong>1</strong>, a pseudo-class (a <strong>:hover</strong> for instance) values <strong>10</strong>, and an id (<strong>#class_x</strong> for instance) values <strong>100</strong>. (wow that&#8217;s a lot of theory right there! <img src='http://blog.templatix.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p></blockquote>
<p>Now if we count the 2 rules above, for the first one we have <strong>#menu ul</strong> (100+1=<strong>101</strong>) and for the second one we have <strong>li:hover ul</strong> (10+1=<strong>11</strong>). From this simple math you can now understand how come that a &#8220;more general&#8221; rule can be out-smarted by a &#8220;more private&#8221; one, even when logics and common-sense tell you the opposite. What can be done? Simply: increase the &#8220;value&#8221; of the second rule:</p>
<pre>#menu li:hover ul {display: block;}</pre>
<p>Now we have <strong>#menu li:hover ul</strong> (100+10+1=<strong>111&gt;101</strong>), which solves the problem (see the result <a title=":hover - phase 3" href="http://blog.templatix.org/wp-content/uploads/2007/02/hover_3.html" target="_blank">here</a>).</p>
<p>If we further add some more styling to spice things up a bit,</p>
<pre>#menu   {width: 10em;}
ul      {margin: 0px; padding: 0px;}
ul ul   {padding-left: 10px;}
li      {list-style-type: none;}
#menu a {display: block; margin: 0; padding: 2px 3px;}
a       {background-color: #CCCCCC; text-decoration: none;
        font-family: Verdana; font-size: 11px;}
a:hover {background-color: #EAEAEA;}</pre>
<p>we get <a title=":hover - phase 4" href="http://blog.templatix.org/wp-content/uploads/2007/02/hover_4.html" target="_blank">something</a> that really starts to look like a menu. And all this, WITHOUT ANY JAVASCRIPT, with a simple, clean code that, when needed, degrades gracefully, clearly and in a structured manner in any more limited browser, so it&#8217;s easy to use in virtually any environment. From here on (for this example) your imagination in making it look pretty is the only limit.</p>
<p><strong>IE5/6? </strong></p>
<p>These two retarded browsers won&#8217;t EVER understand what we&#8217;ve been talking about so far. It&#8217;s by sheer dumb luck that the gentlemen at M$ allowed us to redefine the way some HTML tags work by using sets of rules in <strong>.htc</strong> files. Since this is a completely different story, I&#8217;m just going to send you reading what others, wiser guys, have to say about this, <a href="http://www.xs4all.nl/~peterned/csshover.html" target="_blank">here</a>, that&#8217;s IF you have the patience I HAD. The Bottom-line is that the guys from the above link have programmed such an .htc file that suits our :hover needs like a glove, emulating for IE5/6 around 99% from <strong>:hover</strong>&#8216;s behaviour..</p>
<p>In order to make our example work in IE5/6, you&#8217;ll just have to download the file from <a href="http://www.xs4all.nl/~peterned/htc/csshover2.htc" target="_blank">here</a> and to save it in the same folder with the CSS file, then to use conditional comments to force IE (and not only it) to &#8220;read&#8221; some extra stuff, like so:</p>
<pre>&lt;!--[if IE]&gt;
&lt;style type="text/css" media="screen"&gt;
body          {behavior: url(csshover.htc); font-size: 100%;}
&lt;/style&gt;
&lt;![endif]--&gt;</pre>
<p>(we&#8217;re just teaching the &#8220;body&#8221; tag to play by the <strong>behavior: url(csshover.htc);</strong> rules) Since IE will be the only one to understand this crap, other browsers won&#8217;t be affected and we&#8217;ll have gotten exactly what we came for. And, since all thiss crap is inside a comment, it will validate just fine <img src='http://blog.templatix.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  which will work for us again.</p>
<p>Clearly, the list of cross-browser compatibility problems doesn&#8217;t stop here&#8230; So both IE7 and IE5/6 will just mess up our menu, if we tray to make it look at least decent.</p>
<p>The way around this? Yet another &#8220;hack&#8221; from M$ &#8211; the possibility to create CSS definitions conditionally, depending on the detected browser. After some tweaking I got the following set of conditional rule, both for IE7 and for IE5/6:</p>
<pre>&lt;!--[if IE]&gt;
&lt;style type="text/css" media="screen"&gt;
body        {behavior: url(csshover.htc);}
#menu ul li {float: left; width: 100%;}
li          {border-bottom: solid 1px #CCCCCC; margin-bottom: -1px;}
&lt;/style&gt;
&lt;![endif]--&gt;

&lt;!--[if gte IE 7]&gt;
&lt;style type="text/css" media="screen"&gt;
#menu ul li {float: none;}
li          {border-bottom: none 0px; margin-bottom: -4px;}
&lt;/style&gt;
&lt;![endif]--&gt;</pre>
<p>The final file can be seen <a title=":hover - phase 5" href="http://blog.templatix.org/wp-content/uploads/2007/02/hover_5.html" target="_blank">here</a>.<br />
For inspiration, read what <a title="CSS Down Menus - Horizontal and Vertical" href="http://www.tanfa.co.uk/css/examples/css-dropdown-menus.asp" target="_blank">I have read</a> too.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2008/09/hover/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>ACID Test</title>
		<link>http://blog.templatix.org/2008/09/acid-test/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=acid-test</link>
		<comments>http://blog.templatix.org/2008/09/acid-test/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 19:56:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://blog.templatix.org/?p=30</guid>
		<description><![CDATA[Here goes a mighty fine job: a test meant to show just how well implemented is the CSS support in a browser. The test starts from a rendering considered corect (reference) and you get to compare that render with the test-page as viewed in your browser. Extremely interesting for a CSS geek like me&#8230; Acid [...]]]></description>
			<content:encoded><![CDATA[<p>Here goes a mighty fine job: a test meant to show just how well implemented is the CSS support in a browser. The test starts from a rendering considered corect (reference) and you get to compare that render with the test-page as viewed in your browser. Extremely interesting for a CSS geek like me&#8230;  <img src='http://blog.templatix.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a href="http://www.webstandards.org/action/acid2/" title="ACID Test" target="_blank">Acid Test 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.templatix.org/2008/09/acid-test/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

