<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>Geek Notes &#187; CSS</title>
	<atom:link href="http://www.geek-notes.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geek-notes.com</link>
	<description>A web developer's blog: languages, search engines, servers.</description>
	<lastBuildDate>Thu, 12 Nov 2009 01:14:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.5/</creativeCommons:license>
		<item>
		<title>Cascading Style Sheet Switcher</title>
		<link>http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/</link>
		<comments>http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/#comments</comments>
		<pubDate>Tue, 23 May 2006 11:30:55 +0000</pubDate>
		<dc:creator>Maurizio Petrone</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/</guid>
		<description><![CDATA[
This code snippet will allow your users to choose between different styles to apply to your website.
Yes, it&#8217;s a PHP skin selector for websites!
You can view a live example of it in this weblog itself: it&#8217;s the switch style icon on the top right corner (Click it right now!).
Due to an heavy layout restyling, this [...]]]></description>
			<content:encoded><![CDATA[<img src="/wp-content/icons/icon_php.gif" width="80" height="80" class="icon" alt="PHP" />
<p>This code snippet will allow your users to choose between different styles to apply to your website.<br />
Yes, it&#8217;s a <strong>PHP skin selector for websites</strong>!</p>
<p><strike>You can view a live example of it in this weblog itself: it&#8217;s the <strong>switch style</strong> icon on the top right corner (<a href="/switch.php?style=geek" rel="nofollow" title="Change the stylesheet to 'Geek' for this website">Click it right now!</a>).</strike><br />
<em>Due to an heavy layout restyling, this function is no longer available on my blog. Sorry for the inconvenience</em></p>
<p>Here is a little presentation of the features that this little code provides:</p>
<ul>
<li>Have a default style (in absence of previous choices)</li>
<li>Unlimited choices (depending on your fantasy and ability)</li>
<li>Style choose take effect immediately, and site-wide</li>
<li>Switcher link brings you back to the page you were seeing, but restyled</li>
<li>The preference is saved for each user, for successive visits</li>
</ul>
<p>And now, let&#8217;s explain the technique.<br />
<span id="more-23"></span></p>
<p>Before diving directly into the code, I like to spend some words on the idea behind the switcher.</p>
<p>The main thing we do is <strong>printing links to different <acronym title="Cascading Style Sheet">CSS</acronym> files</strong> into our page HTML &lt;head&gt; section, depending on what we read from a <strong>cookie</strong>.</p>
<h4><strong>Why CSS files?</strong></h4>
<p>There are several advantages with having your site presentation and style informations stored into a separate <acronym title="Cascading Style Sheet">CSS</acronym> file, instead of having them embedded directly into the markup.</p>
<p>Without listing all of them, I just say that you can vary the <em>look &#038; feel</em> of a whole site by changing only a single line of code &#8211; that one that tells us the name and the path of <acronym title="Cascading Style Sheet">CSS</acronym> file.</p>
<h4><strong>What I need?</strong></h4>
<p>An (X)HTML output for your website (ok, you already got it); two or more CSS files applicable to that markup output; a server that can run PHP; and a client that can save cookies!</p>
<p>For multiple pages, it would be useful to have a template-driven output, so you don&#8217;t have to change every single page &lt;head&gt; section, but only the template one.</p>
<p>Please note: the more standard, well-formed and separated from presentation your markup code is, the more effective and powerful this technique will be.<br />
(<em>XHTML Strict</em>, without any embedded style information, is the best.)</p>
<h4><strong>How it works?</strong></h4>
<p>Ok, do you have at least two CSS files for your markup? <strong>Let&#8217;s switch &#8216;em!</strong></p>
<p>First of all, change the line that display the link to your CSS with something like this:</p>
<div class="codebox">&lt;link&nbsp;href=&#8221;/path/<span style="color: red">&lt;?php echo $style ?&gt;</span>.css&#8221; rel=&#8221;stylesheet&#8221; type=&#8221;text/css&#8221; /&gt;</div>
<p>Substantially, you have to change the CSS filename (without its extension) with the <em>echo</em> of <span class="codespan">$style</span> variable on PHP.</p>
<p>To fill this variable with a valid value (that is an existing CSS file name in the specified path), put this code immediately before the previous line:</p>
<div class="codebox">&lt;php<br />
if(isset($_COOKIE['style'])){<br />
$style=$_COOKIE['style'];<br />
} else {<br />
$style=&#8217;default&#8217;; //the name of default style file<br />
}<br />
?&gt;</div>
<p>With these lines, we control if there&#8217;s a cookie named STYLE, then assign its value to <span class="codespan">$style</span>, else we assign a default value to that variable.<br />
<em>I guess that you already know what comes next&#8230;</em></p>
<p>The last thing to do is to write a script that will write a custom value (that is CSS name) in our cookie, and then send the client back to the page it was on before calling that script.</p>
<p>Create an empty file called switch.php and fill it with the following:</p>
<div class="codebox">&lt;?php setcookie(&#8221;style&#8221;, $_GET["style"], time()+31536000);<br />
header(&#8221;Location:&#8221;.$HTTP_SERVER_VARS["HTTP_REFERER"]);<br />
?></div>
<p>You can call it from any page with a link like this:</p>
<div class="codebox">&lt;a&nbsp;href=&#8221;/switch.php?style=default&#8221;&gt;View page with Default style!&lt;/a&gt;<br />
&lt;a&nbsp;href=&#8221;/switch.php?style=alternate&#8221;&gt;View page with Alternate style!&lt;/a&gt;</div>
<p>When you click the link, the page reloads: the cookie will be read and the new style link will be shown, and the page from where you clicked on the switcher link will be styled accordingly!</p>
<div class="sociable"><span class="sociable_tagline"><strong>Bookmark:</strong><span>These icons link to social bookmarking sites where readers can share and discover new web pages.</span></span><ul>
	<li><a href="http://digg.com/submit?phase=2&amp;url=http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/&amp;title=Cascading+Style+Sheet+Switcher" title="digg"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/digg.png" alt="digg" /></a></li>
	<li><a href="http://del.icio.us/post?url=http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/&amp;title=Cascading+Style+Sheet+Switcher" title="del.icio.us"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/delicious.png" alt="del.icio.us" /></a></li>
	<li><a href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/&amp;title=Cascading+Style+Sheet+Switcher" title="blogmarks"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/blogmarks.png" alt="blogmarks" /></a></li>
	<li><a href="http://co.mments.com/track?url=http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/&amp;title=Cascading+Style+Sheet+Switcher" title="co.mments"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/co.mments.gif" alt="co.mments" /></a></li>
	<li><a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/&amp;h=Cascading+Style+Sheet+Switcher" title="NewsVine"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/newsvine.png" alt="NewsVine" /></a></li>
	<li><a href="http://www.furl.net/storeIt.jsp?u=http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/&amp;t=Cascading+Style+Sheet+Switcher" title="Furl"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/furl.png" alt="Furl" /></a></li>
</ul></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.5/</creativeCommons:license>
	</item>
		<item>
		<title>Design &amp; Layout remake for Geek notes</title>
		<link>http://www.geek-notes.com/css/22/design-layout-remake-for-geek-notes/</link>
		<comments>http://www.geek-notes.com/css/22/design-layout-remake-for-geek-notes/#comments</comments>
		<pubDate>Mon, 22 May 2006 01:00:24 +0000</pubDate>
		<dc:creator>Maurizio Petrone</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.geek-notes.com/css/22/design-layout-remake-for-geek-notes/</guid>
		<description><![CDATA[
Welcome to my completely re-fashioned weblog!
I&#8217;ve worked a lot on it, and this second-version design is supposed to:

make the page look cleaner and text more readable,
put a strong focus on contents,
reduce the number of used colours and put things in order.

Okay, but what about the first-version design? I&#8217;d liked it&#8230;
Don&#8217;t worry: just click on the [...]]]></description>
			<content:encoded><![CDATA[<img src="/wp-content/icons/icon_css.gif" width="80" height="80" class="icon" alt="CSS" />
<p><strong>Welcome to my completely re-fashioned weblog!<br />
</strong>I&#8217;ve worked a lot on it, and this second-version design is supposed to:</p>
<ul>
<li>make the page look cleaner and text more readable,</li>
<li>put a strong focus on contents,</li>
<li>reduce the number of used colours and put things in order.</li>
</ul>
<p><strong>Okay, but what about the first-version design? I&#8217;d liked it&#8230;</strong></p>
<p>Don&#8217;t worry: just click on the <strong>style-switch</strong> image in the top-right corner: the page will reload, and from that moment on you&#8217;ll have the whole <strong>site styled as you want, every time you come back!</strong></p>
<p>And now, <strong>it&#8217;s poll time</strong>: do you like this work or not? I&#8217;d like to know your opinion: you can just vote the poll, or leave a comment to send detailed feedback.</p>
<div>
<form action="http://www.geek-notes.com/wp-content/plugins/democracy/democracy.php?jal_nojs=true" method="post" id="democracyForm" onsubmit="return ReadVote();">
<div id="democracy">
<h5 title="Click on the image preview to see the style LIVE in action; check the option and click VOTE to cast your preference">Which layout do you prefer?</h5>
<ul>
<li>
            	<label for="choice_1"></p>
<input type="radio" id="choice_1" value="1" name="poll_aid" />
            		<a title="Switch to LIGHT layout" href="/switch.php?style=light" rel="nofollow"><img src="/files/light_preview.png" alt="vote for LIGHT layout" style="border:0" /><br/><b>Light</b></a>            	</label>
            </li>
<li>
            	<label for="choice_2"></p>
<input type="radio" id="choice_2" value="2" name="poll_aid" />
            		<a title="Switch to GEEK layout" href="/switch.php?style=geek" rel="nofollow"><img src="/files/geek_preview.png" alt="vote for GEEK layout" style="border:0" /><br/><b>Geek</b></a>            	</label>
            </li>
</ul>
<p>
<input type="hidden" id="poll_id" name="poll_id" value="1" />
<input type="submit" name="vote" value="Vote" /></p>
<p>        	<a id="view-results" href="/category/css/feed/?jal_no_js=true&amp;poll_id=1">View Results</a>
        	        </p>
</p></div>
</p></form>
</div>
<h4>Some notes on this work:</h4>
<p>New design is all made out by <strong>Cascading Style Sheets</strong> (which are valid, of course): when you click on the switcher, the <acronym title="eXtensible HyperText Markup Language">XHTML</acronym> source code of the page remains the same; the only thing that vary are the links to <acronym title="Cascading Style Sheet">CSS</acronym> files.</p>
<p>That&#8217;s the truly power of <acronym title="Cascading Style Sheet">CSS</acronym>: by separating structure and presentation, you can vary the presentation with just a line of code in the markup, and the new stylesheet will be applied site-wide.</p>
<p>Last, but not least, the new <em>LIGHT</em> cascading style sheet was tested (as well as the <em>GEEK</em> one) on: Firefox, Internet Explorer (both 6 and 7-beta), and Opera 8.<br />
<em>Safari users, do you see errors?</em></p>
<p>P.s. <strong><em>Do you want to know how the style switcher works?</em></strong><br />
Let&#8217;s check out the <a href="http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/" title="Cascading Style Sheet Switcher in PHP">explanation of this PHP Cascading Style Sheet Switcher</a>!</p>
<div class="sociable"><span class="sociable_tagline"><strong>Bookmark:</strong><span>These icons link to social bookmarking sites where readers can share and discover new web pages.</span></span><ul>
	<li><a href="http://digg.com/submit?phase=2&amp;url=http://www.geek-notes.com/css/22/design-layout-remake-for-geek-notes/&amp;title=Design+%26+Layout+remake+for+Geek+notes" title="digg"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/digg.png" alt="digg" /></a></li>
	<li><a href="http://del.icio.us/post?url=http://www.geek-notes.com/css/22/design-layout-remake-for-geek-notes/&amp;title=Design+%26+Layout+remake+for+Geek+notes" title="del.icio.us"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/delicious.png" alt="del.icio.us" /></a></li>
	<li><a href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://www.geek-notes.com/css/22/design-layout-remake-for-geek-notes/&amp;title=Design+%26+Layout+remake+for+Geek+notes" title="blogmarks"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/blogmarks.png" alt="blogmarks" /></a></li>
	<li><a href="http://co.mments.com/track?url=http://www.geek-notes.com/css/22/design-layout-remake-for-geek-notes/&amp;title=Design+%26+Layout+remake+for+Geek+notes" title="co.mments"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/co.mments.gif" alt="co.mments" /></a></li>
	<li><a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.geek-notes.com/css/22/design-layout-remake-for-geek-notes/&amp;h=Design+%26+Layout+remake+for+Geek+notes" title="NewsVine"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/newsvine.png" alt="NewsVine" /></a></li>
	<li><a href="http://www.furl.net/storeIt.jsp?u=http://www.geek-notes.com/css/22/design-layout-remake-for-geek-notes/&amp;t=Design+%26+Layout+remake+for+Geek+notes" title="Furl"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/furl.png" alt="Furl" /></a></li>
</ul></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geek-notes.com/css/22/design-layout-remake-for-geek-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.5/</creativeCommons:license>
	</item>
		<item>
		<title>IE &#8216;three pixel bug&#8217; hacked with float</title>
		<link>http://www.geek-notes.com/xhtml/1/ie-three-pixel-bug-hacked-with-float/</link>
		<comments>http://www.geek-notes.com/xhtml/1/ie-three-pixel-bug-hacked-with-float/#comments</comments>
		<pubDate>Wed, 03 May 2006 16:00:41 +0000</pubDate>
		<dc:creator>Maurizio Petrone</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.geek-notes.com/xhtml/1/ie-three-pixel-bug-hacked-with-float/</guid>
		<description><![CDATA[
Internet Explorer has a rendering bug called &#8220;Three pixel gap&#8221;.
Substantially, any box, also ones nested into another, that is next to a floated box gets a shrink of three pixel in the same direction of the float.
I&#8217;ve prepared an example to show this. The example document has a valid code for style and markup, then [...]]]></description>
			<content:encoded><![CDATA[<img src="/wp-content/icons/icon_css.gif" width="80" height="80" class="icon" alt="CSS" />
<p>Internet Explorer has a rendering bug called &#8220;Three pixel gap&#8221;.<br />
Substantially, <strong>any box, also ones nested into another, that is next to a floated box gets a shrink of three pixel in the same direction of the float</strong>.</p>
<p>I&#8217;ve prepared an example to show this. The example document has a valid code for style and markup, then it works well with standard-compliant browser like Firefox. But <a href="http://www.geek-notes.com/files/ie_bug_float.htm">try to open this page with Internet Explorer to see the bug in action</a>.</p>
<p>This bug is known, and there&#8217;s already an hack for it. <a href="http://www.positioniseverything.net/explorer/threepxtest.html">Here is a detailed description</a> of both the bug and the hack.<br />
The known hack consists into assign <span class="codespan">height:1%</span> to the buggy box.<br />
<strong> But this hack did not seem working to me</strong>, as you can see from the example source code: <span class="codespan">height:1%</span> has no effect <em>(I suppose it&#8217;s due to the fact that buggy boxes are contained into another, non-floated one &#8211; which the blue-bordered one in the example above)</em>.</p>
<h4><strong>So, I&#8217;ve prepared a different hack.</strong></h4>
<p><span id="more-1"></span>The trick is to <strong>declare floated the box containing the buggy boxes</strong>, and to <strong>fix its margin</strong> using <span class="codespan">!important</span> flag.<br />
<a href="http://www.geek-notes.com/files/ie_hack_float.htm">Here you can see an example of the same page, hacked for Internet Explorer</a>.<br />
<em> Please note: this hack works only with Internet Explorer (tested on v. 5.01 and above). It messes up things other browsers.<br />
</em></p>
<p>The code is really simple. Focusing on example shown above, <span class="spancode">div#container</span> is the box with blue border. It&#8217;s not buggy itself, but it nests the buggy boxes. Here is its CSS code:</p>
<div class="codebox">#container { 	float:left; 	margin-left:18px!important; 	margin-right:28px!important 	}</div>
<p>Of course, if you want to have a document that fits both IE and other browsers, you must have this code interpreted by I.E. only.</p>
<p>Via CSS, you can use &#8220;the star&#8221;. A CSS paragraph that follows <span class="codespan">* html</span> runs only on IE.<br />
Better, you can use <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp"><em>conditional comments</em></a> to put a link to your hacked stylesheet (as I do).</p>
<div class="sociable"><span class="sociable_tagline"><strong>Bookmark:</strong><span>These icons link to social bookmarking sites where readers can share and discover new web pages.</span></span><ul>
	<li><a href="http://digg.com/submit?phase=2&amp;url=http://www.geek-notes.com/xhtml/1/ie-three-pixel-bug-hacked-with-float/&amp;title=IE+%27three+pixel+bug%27+hacked+with+float" title="digg"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/digg.png" alt="digg" /></a></li>
	<li><a href="http://del.icio.us/post?url=http://www.geek-notes.com/xhtml/1/ie-three-pixel-bug-hacked-with-float/&amp;title=IE+%27three+pixel+bug%27+hacked+with+float" title="del.icio.us"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/delicious.png" alt="del.icio.us" /></a></li>
	<li><a href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://www.geek-notes.com/xhtml/1/ie-three-pixel-bug-hacked-with-float/&amp;title=IE+%27three+pixel+bug%27+hacked+with+float" title="blogmarks"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/blogmarks.png" alt="blogmarks" /></a></li>
	<li><a href="http://co.mments.com/track?url=http://www.geek-notes.com/xhtml/1/ie-three-pixel-bug-hacked-with-float/&amp;title=IE+%27three+pixel+bug%27+hacked+with+float" title="co.mments"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/co.mments.gif" alt="co.mments" /></a></li>
	<li><a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.geek-notes.com/xhtml/1/ie-three-pixel-bug-hacked-with-float/&amp;h=IE+%27three+pixel+bug%27+hacked+with+float" title="NewsVine"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/newsvine.png" alt="NewsVine" /></a></li>
	<li><a href="http://www.furl.net/storeIt.jsp?u=http://www.geek-notes.com/xhtml/1/ie-three-pixel-bug-hacked-with-float/&amp;t=IE+%27three+pixel+bug%27+hacked+with+float" title="Furl"><img src="http://www.geek-notes.com/wp-content/plugins/sociable/images/furl.png" alt="Furl" /></a></li>
</ul></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geek-notes.com/xhtml/1/ie-three-pixel-bug-hacked-with-float/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.5/</creativeCommons:license>
	</item>
	</channel>
</rss>
