<?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>Travis, Travaganza &#187; CSS</title>
	<atom:link href="http://www.travislin.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.travislin.com</link>
	<description>Web Design, Technologies and Fancy photos of what I see.</description>
	<lastBuildDate>Wed, 25 Jan 2012 05:44:22 +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>SE Track &#8211; Customise Tag List with CSS</title>
		<link>http://www.travislin.com/2009/12/customise-tag-list-with-css/</link>
		<comments>http://www.travislin.com/2009/12/customise-tag-list-with-css/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 12:44:55 +0000</pubDate>
		<dc:creator>Travis</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[StackExchange]]></category>
		<category><![CDATA[StackExchange Beta 5]]></category>
		<category><![CDATA[Tag List]]></category>

		<guid isPermaLink="false">http://www.travislin.com/?p=157</guid>
		<description><![CDATA[While hacking away my StackExchange site: Zerg Overflow, I use couple of tricks that one can use to customise their website design without modifying existing HTML structure. I will start a series of CSS/jQuery tricks that uses StackExchange platform as &#8230; <a href="http://www.travislin.com/2009/12/customise-tag-list-with-css/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While hacking away my <a title="Link to StackExchange homepage" href="http://stackexchange.com/" target="_blank">StackExchange</a> site: <a title="Link to Zerg Overflow homepage" href="http://zergoverflow.com/" target="_blank">Zerg Overflow</a>, I use couple of tricks that one can use to customise their website design without modifying existing HTML structure. I will start a series of CSS/jQuery tricks that uses StackExchange platform as example but yet can be utilise in any other way.</p>
<p>In StackExchange sites, tags for questions are listed in horizontally and depends on the contents of tags, I want to place a customised icon in front of the tag list. This can be done with a simple CSS. First, let&#8217;s understand the HTML semantics here in StackExchange.</p>
<p><a href="http://www.travislin.com/wp-content/uploads/2009/12/tags_icon_2009-12-03.jpg"><img class="aligncenter size-medium wp-image-159" title="tags_icon_2009-12-03" src="http://www.travislin.com/wp-content/uploads/2009/12/tags_icon_2009-12-03-300x74.jpg" alt="tags_icon_2009-12-03" width="300" height="74" /></a>In element <code>&lt;div&gt;</code> you will find tag name appears as class name with a <code>t-</code> prefix. For example:</p>
<pre class="brush:html">
<div class="tags t-canada t-business t-tips">
    <a class="post-tag" title="..." rel="tag" href="...">canada</a>
    <a class="post-tag" title="..." rel="tag" href="...">business</a>
    <a class="post-tag" title="..." rel="tag" href="...">tips</a></div>
</pre>
<p>Use CSS to create a space in front of the tags bar (by using padding) and add a background image like this:</p>
<pre class="brush:css">.t-canada {
    padding: 0 0 0 [IMAGE WIDTH]px;
    background: url(http://[URL]/canada_flag.gif) no-repeat 0 50% transparent;
}</pre>
<p>There! You have an &#8216;canada&#8217; related icon appear in front of the tags bar when &#8216;canada&#8217; tag is mentioned.</p>
<p>This will only show 1 image per question and that&#8217;s its feature. If multiple tags are triggered to show icon, <strong>then the later one in CSS will be shown</strong>. So sort your tags priority if needed.</p>
<h3><span style="font-weight: normal;">Short come</span></h3>
<p>This is sort of semi-automatic, you will have to update/add CSS whenever you have new tag you want to trigger.</p>
<h3><span style="font-weight: normal;">Something to watch out for</span></h3>
<p>In &#8216;Unanswered&#8217; page, the tags bar is <strong>fixed width of 410px</strong>. Adding paddings may cause your tags bar move to undesired position (below user-info box rather the next to it). This can be resolved by modify tags bar width:</p>
<pre class="brush:css">.excerpt .t-canada {
    width: [410 - PADDING WIDTH]px !important;
}</pre>
<h3><span style="font-weight: normal;">Potential Problem</span></h3>
<p>If your tags ever have more than 1 line, the position of your image may seems weird as it will sit in the left middle of 2 lines. I&#8217;m not taking this into account as having maximum of 5 tags to go over 410px is kind of hard with default font-size and margin.</p>
<p>However if it bothers you, you can change the backgroup position to appear on top left corner instead:</p>
<pre class="brush:css">.t-canada {
    padding: 0 0 0 [IMAGE WIDTH]px;
    background: url(http://[URL]/canada_flag.gif) no-repeat 0 0 transparent;
}</pre>
<h3><span style="font-weight: normal;">Alternative Solution</span></h3>
<p>If you want icon to appear <strong>inside individual tag</strong> instead of beginning of tags bar, then you will need to use some javascript trick to make it happen. <strong>OR</strong> maybe in the coming beta(s), we can have tag name in <code>&lt;a&gt;</code> element like this:</p>
<pre class="brush:html">
<div class="tags t-happy">
    <a class="post-tag pt-happy" title="..." rel="tag" href="...">happy</a></div>
</pre>
<p><em>Note: <strong>pt-</strong> prefix stands for post tag.</em></p>
<p>Feel free to leave your feedback on <a title="Link to StackExchange Meta page of this topic" href="http://meta.stackexchange.com/questions/1098/pushing-se-to-the-max-some-cool-techniques-you-can-use/3093#3093" target="_blank">StackExchange Meta</a> or commenting on this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.travislin.com/2009/12/customise-tag-list-with-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add external link icon after all external links using jQuery</title>
		<link>http://www.travislin.com/2009/05/add-external-link-icon-after-all-external-links-using-jquery/</link>
		<comments>http://www.travislin.com/2009/05/add-external-link-icon-after-all-external-links-using-jquery/#comments</comments>
		<pubDate>Sat, 09 May 2009 07:42:54 +0000</pubDate>
		<dc:creator>Travis</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML styling]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.travislin.com/?p=31</guid>
		<description><![CDATA[Here is a very simple tutorial on how you can automatically insert an icon image after external (also known as off-site) links by using jQuery javacript framework. For those who are not familiar with jQuery: jQuery is a lightweight JavaScript &#8230; <a href="http://www.travislin.com/2009/05/add-external-link-icon-after-all-external-links-using-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-medium wp-image-38" title="p03-ss02" src="http://www.travislin.com/wp-content/uploads/2009/05/p03-ss02-300x194.gif" alt="p03-ss02" width="300" height="194" /></p>
<p>Here is a very simple tutorial on how you can automatically insert an icon image after external (also known as off-site) links by using <a class="external_icon" title="jQuery Framework Homepage" href="http://jquery.com/" target="_blank">jQuery javacript framework</a>.<span id="more-31"></span></p>
<p>For those who are not familiar with jQuery:</p>
<blockquote><p>jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML. It was released January 2006 at BarCamp NYC by John Resig.</p></blockquote>
<p style="text-align: center;"><em>Description of jQuery quoted from <a class="external_icon" title="Wikipedia page: jQuery" href="http://en.wikipedia.org/wiki/JQuery" target="_blank">Wikipedia</a>.</em></p>
<p>Reason I choose to go with javscript implementation instead of pure CSS is so that you do not have go through your entire blog to specified every link that you want to be marked as external link &#8211; leave this job to computer!</p>
<p>(Note: You also able to achieve this automatically using <a class="external_icon" title="Programmabilities: External Link Icons with CSS Selectors" href="http://programmabilities.com/xml/?id=30" target="_blank">CSS3 selector</a>, however CSS3 implementation is still in draft and is<a class="external_icon" title="Wikipedia: Comparison of layout engines" href="http://en.wikipedia.org/wiki/Comparison_of_layout_engines_%28CSS%29" target="_blank"> still not fully supported by browsers</a>.)</p>
<p>I will be using jQuery 1.3.2, the latest version to-date. Add the follwing javscript to your page:</p>
<pre class="brush:php">
<script language="javascript" type="text/javascript">
<!--	
	(function($)
	{
		$(document).ready(function()
		{
			/* Add class to all anchor targeting a blank page */
			$("a[target=''_blank'']").addClass("external_icon");
		});
	}(jQuery));
//-->
</script>
</pre>
<p>This javascript selects anchors that has target=”_blank” attributes on them and gives those anchors a new class “external_icon”.</p>
<p>Next step would be applying style to those anchors with “external_icon” class:</p>
<pre class="brush:css">
a.external_icon {
	background: url(images/external-link.gif) no-repeat 100% 50%;
	padding-right: 12px;
}
</pre>
<p>That&#8217;s it! 2 steps, very simple as promised. However couple of things you may want to watch out for. Below is couple of tweaks you may consider adding.</p>
<h3>Image Exception</h3>
<p>Having a small external link icon next to an image looks worse than without it, you may examption to anchored images by:</p>
<pre class="brush:php">
<script language="javascript" type="text/javascript">
<!--
	(function($)
	{
		$(document).ready(function()
		{
			/* Add class to all anchor targeting a blank page */
			$("a[target=''_blank'']").addClass("external_icon");

			/* Remove class if anchor is on an image */
			$("a[target=''_blank''] img").parent().removeClass("external_icon");
		});
	}(jQuery));
//-->
</script>
</pre>
<h3>Specified Anchor Exclusion</h3>
<p>If there are certain links in the post that you feel like not having an external link icon and want to exclude them from applying the style, then specified a &#8220;no_external_icon&#8221; class to those links and have your javascript code as follow:</p>
<pre class="brush:php">
<script language="javascript" type="text/javascript">
<!--
	(function($)
	{
		$(document).ready(function()
		{
			/* Add class to all anchor targeting a blank page */
			$("a[target=''_blank'']").addClass("external_icon");

			/* Remove class if anchor is on an image */
			$("a[target=''_blank''] img").parent().removeClass("external_icon");

			/* Remove class if anchor is specified not to have external icon */
			$("a[target=''_blank''].no_external_icon").removeClass("external_icon");
		});
	}(jQuery));
//-->
</script>
</pre>
<p>Now you have it! Try the code out yourself!</p>
<p><span style="color: #ff0000;"><em><strong>Edit on 2009-05-12:</strong></em></span></p>
<p>Thanks to <a title="GunnerPress Homepage" rel="external nofollow" href="http://www.travislin.com/2009/05/add-external-link-icon-after-all-external-links-using-jquery/#comment-2">J Mehmett</a> for pointing out that <code>target="_blank"</code> is invalid in XHTML 1.0 Strict (however remain valid in XHTML 1.0 Transitional and HTML 4.01 Transitional as <code>target</code> attribute is not yet deprecated).</p>
<p>In that case:</p>
<h3>Specified Relationship Inclusion</h3>
<p>Advanced web developers has slowly stop the usage of <code>target</code> and using <code>rel</code> attribute instead.</p>
<pre class="brush:php">
<script language="javascript" type="text/javascript">
<!--
	(function($)
	{
		$(document).ready(function()
		{
			/* Add class to all anchor targeting a blank page */
			$("a[rel=''external'']").addClass("external_icon");

			/* Open external links as a new tab/page */
			$("a[rel=''external'']").click(function(){
				this.target = "_blank";
			});
		});
	}(jQuery));
//-->
</script>
</pre>
<p>Without too much trouble, we can achieve the same result by using above!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.travislin.com/2009/05/add-external-link-icon-after-all-external-links-using-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

