<?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>Lea Verou &#187; Replies</title>
	<atom:link href="http://lea.verou.me/category/replies/feed/" rel="self" type="application/rss+xml" />
	<link>http://lea.verou.me</link>
	<description>Life at the bleeding edge (of web standards)</description>
	<lastBuildDate>Thu, 02 Feb 2012 14:08:08 +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>Better “CSS3 ticket-like tags”</title>
		<link>http://lea.verou.me/2011/08/better-css3-ticket-like-tags/</link>
		<comments>http://lea.verou.me/2011/08/better-css3-ticket-like-tags/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 20:50:55 +0000</pubDate>
		<dc:creator>Lea Verou</dc:creator>
				<category><![CDATA[Replies]]></category>
		<category><![CDATA[CSS gradients]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[generated content]]></category>

		<guid isPermaLink="false">http://leaverou.me/?p=1210</guid>
		<description><![CDATA[Today I stumbled upon this tutorial, which from the screenshot, looked very interesting. So, I read on, and to my horror I noticed the author suggesting some questionable practices, the worst of which was using 3 HTML elements for every tag, including nonsense markup like &#60;span class="circle"&#62;&#60;/span&#62;. So, I thought I’d take a chance at trying [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_hot-pink" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Flea.verou.me%252F2011%252F08%252Fbetter-css3-ticket-like-tags%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FmQW7QD%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Better%20%E2%80%9CCSS3%20ticket-like%20tags%E2%80%9D%22%20%7D);"></div>
<p>Today I stumbled upon <a href="http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-create-pure-css3-ticket-like-tags/" target="_blank">this</a> tutorial, which from the screenshot, looked very interesting. So, I read on, and to my horror I noticed the author suggesting some questionable practices, the worst of which was using 3 HTML elements for every tag, including nonsense markup like <code>&lt;span class="circle"&gt;&lt;/span&gt;</code>.</p>
<p>So, I thought I’d take a chance at trying to recreate this effect without any extra markup. And it turned out to be quite easy, although using CSS gradients limits browser support a bit (IE10, Firefox 3.6+, Chrome, Safari 5.1).</p>
<p>They have the same disadvantage as the originals: They depend on the background color. However, unlike the originals, they come at less code, they&#8217;re scalable without changing a million values (as shown in the &#8220;bigger&#8221; section) and of course, no extra markup.</p>
<p>You can see the results in <a href="http://jsfiddle.net/leaverou/T9bmw/" target="_blank">the fiddle</a> below:</p>
<p><iframe style="width: 100%; height: 400px" src="//jsfiddle.net/leaverou/T9bmw/embedded/result%2Ccss%2Chtml"></iframe></p>
<p>Disclaimer: <a href="http://webdesign.tutsplus.com/" target="_blank">webdesign tuts+</a> occasionally has some nice tutorials. I didn&#8217;t write this post to attack them in any way.</p>

]]></content:encoded>
			<wfw:commentRss>http://lea.verou.me/2011/08/better-css3-ticket-like-tags/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Styling children based on their number, with CSS3</title>
		<link>http://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/</link>
		<comments>http://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 20:40:35 +0000</pubDate>
		<dc:creator>Lea Verou</dc:creator>
				<category><![CDATA[Replies]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[CSS3 selectors]]></category>

		<guid isPermaLink="false">http://leaverou.me/?p=825</guid>
		<description><![CDATA[The original idea belongs to André Luís, but I think it could be improved to be much less verbose. André&#8217;s solution is like this: /* one item */ li:nth-child(1):nth-last-child(1) { width: 100%; } /* two items */ li:nth-child(1):nth-last-child(2), li:nth-child(2):nth-last-child(1) { width: 50%; } /* three items */ li:nth-child(1):nth-last-child(3), li:nth-child(2):nth-last-child(2), li:nth-child(3):nth-last-child(1) { width: 33.3333%; } /* [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_hot-pink" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Flea.verou.me%252F2011%252F01%252Fstyling-children-based-on-their-number-with-css3%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FekAbp3%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Styling%20children%20based%20on%20their%20number%2C%20with%20CSS3%22%20%7D);"></div>
<p>The <a href="http://andr3.net/blog/post/142" target="_blank">original idea belongs to André Luís</a>, but I think it could be improved to be much less verbose.</p>
<p>André&#8217;s solution is like this:</p>
<pre>/* one item */
li:nth-child(1):nth-last-child(1) {
	width: 100%;
}

/* two items */
li:nth-child(1):nth-last-child(2),
li:nth-child(2):nth-last-child(1) {
	width: 50%;
}

/* three items */
li:nth-child(1):nth-last-child(3),
li:nth-child(2):nth-last-child(2),
li:nth-child(3):nth-last-child(1) {
	width: 33.3333%;
}

/* four items */
li:nth-child(1):nth-last-child(4),
li:nth-child(2):nth-last-child(3),
li:nth-child(3):nth-last-child(2),
li:nth-child(4):nth-last-child(1) {
	width: 25%;
}</pre>
<p>It&#8217;s based on the relationship between :nth-child and :nth-last-child. As you can see, the number of total rules is O(N) and the number of selectors in every rule is also O(N).</p>
<p>However, what you really want, is to just target the first element. The others can be targeted with just a sibling selector. With my improvement, the number of total rules is still O(N), but the number of selectors in every rule becomes just 2, making this trick practical for far larger numbers of children:</p>
<pre>/* one item */
li:first-child:nth-last-child(1) {
	width: 100%;
}

/* two items */
li:first-child:nth-last-child(2),
li:first-child:nth-last-child(2) ~ li {
	width: 50%;
}

/* three items */
li:first-child:nth-last-child(3),
li:first-child:nth-last-child(3) ~ li {
	width: 33.3333%;
}

/* four items */
li:first-child:nth-last-child(4),
li:first-child:nth-last-child(4) ~ li {
	width: 25%;
}</pre>
<p>And here&#8217;s a fiddle to prove it:<br />
<iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/leaverou/HdfaT/embedded/result,css,html"></iframe></p>
<p>Yes, I know that with Flexbox and the other layout modules, techniques such as these are soon becoming obsolete, but I think they are still useful right now.<br />
I&#8217;m also aware that you can emulate this particular example with table display modes, but a) Table display modes have other implications that are sometimes undesirable and b) Widths are just an example, you could come up with other ways to style the elements based on their total count, which can&#8217;t be emulated by CSS tables.</p>

]]></content:encoded>
			<wfw:commentRss>http://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>CSSNinja&#8217;s custom forms revisited to work with CSS sprites</title>
		<link>http://lea.verou.me/2010/02/cssninjas-custom-forms-revisited-to-work-with-css-sprites/</link>
		<comments>http://lea.verou.me/2010/02/cssninjas-custom-forms-revisited-to-work-with-css-sprites/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 09:07:02 +0000</pubDate>
		<dc:creator>Lea Verou</dc:creator>
				<category><![CDATA[Replies]]></category>
		<category><![CDATA[CSS3 selectors]]></category>

		<guid isPermaLink="false">http://leaverou.me/?p=512</guid>
		<description><![CDATA[I read today CSS Ninja&#8216;s (Ryan Sheddon&#8217;s) brilliant new technique about the creation of custom checkboxes and radio buttons with CSS alone. The only thing that bugged me about it was something he pointed himself out as well: This technique has only 1 drawback I can think of, IE support is not a drawback for [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_hot-pink" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Flea.verou.me%252F2010%252F02%252Fcssninjas-custom-forms-revisited-to-work-with-css-sprites%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22CSSNinja%27s%20custom%20forms%20revisited%20to%20work%20with%20CSS%20sprites%22%20%7D);"></div>
<p>I read today <a href="http://www.thecssninja.com/" target="_blank">CSS Ninja</a>&#8216;s (Ryan Sheddon&#8217;s) <a href="http://www.thecssninja.com/css/custom-inputs-using-css">brilliant new technique about the creation of custom checkboxes and radio buttons with CSS alone</a>.</p>
<p>The only thing that bugged me about it was something he pointed himself out as well:</p>
<blockquote><p>This technique has only 1 drawback I can think of, IE support is not a drawback for me, you can’t use a big sprite image to save all the radio and checkbox states, they need to be individual images. Using CSS generated content to insert an image doesn’t give you control of the image position like a background image does.</p></blockquote>
<p>And then I wondered &#8220;but hey, <strong>why</strong> can&#8217;t we use background images?&#8221;. It seemed pretty obvious to me that we could combine a transparent text color with normal css sprites and a display of inline-block in the ::before pseudo-element to achieve the exact same effect. I verified that my initial assertion was actually correct, and tested it in Firefox, Chrome, Safari and Opera (the latest only, no time for testing in older ones at the moment) and it seems to work fine.</p>
<p>Here it is: <a href="http://lea.verou.me/demos/cssninja-custom-forms/">demo</a> | <a href="http://lea.verou.me/demos/cssninja-custom-forms/source.zip">source files (including .psd file of the sprite)</a></p>
<p>I&#8217;m afraid there&#8217;s some blatantly obvious drawback in my approach that made Ryan prefer his method over this, but I&#8217;m posting it just in case&#8230;</p>

]]></content:encoded>
			<wfw:commentRss>http://lea.verou.me/2010/02/cssninjas-custom-forms-revisited-to-work-with-css-sprites/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A CSS3 learning(?) tool</title>
		<link>http://lea.verou.me/2009/10/a-css3-learning-tool/</link>
		<comments>http://lea.verou.me/2009/10/a-css3-learning-tool/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 06:52:01 +0000</pubDate>
		<dc:creator>Lea Verou</dc:creator>
				<category><![CDATA[Apps & scripts]]></category>
		<category><![CDATA[Replies]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[CSS3 properties]]></category>

		<guid isPermaLink="false">http://leaverou.me/?p=414</guid>
		<description><![CDATA[In case anyone is interested, this is my take on the &#8220;challenge&#8221; that Brad Neuberg posted today on Ajaxian. It needs more properties, but it&#8217;s very easy to extend. I guess I should also add CSS3 values (RGBA/HSL(A) colors, CSS gradients etc) but oh well, I&#8217;m currently in a hurry. I will, if anyone actually [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_hot-pink" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Flea.verou.me%252F2009%252F10%252Fa-css3-learning-tool%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FnKRqEx%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22A%20CSS3%20learning%28%3F%29%20tool%22%20%7D);"></div>
<p>In case anyone is interested, <a href="http://lea.verou.me/scripts/css3learn.html">this is my take</a> on the <a href="http://ajaxian.com/archives/interactive-css-3-generator" target="_blank">&#8220;challenge&#8221; that Brad Neuberg posted today on Ajaxian</a>. It needs more properties, but it&#8217;s very easy to extend. I guess I should also add CSS3 values (RGBA/HSL(A) colors, CSS gradients etc) but oh well, I&#8217;m currently in a hurry. I will, if anyone actually finds it useful (?).</p>
<p>It didn&#8217;t prove much of a challenge actually and I honestly doubt it&#8217;s educational value (actually it&#8217;s value in general), but it was an interesting thing to do while drinking my first coffee in the morning &#8212; I really enjoyed writing it <img src='http://lea.verou.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

]]></content:encoded>
			<wfw:commentRss>http://lea.verou.me/2009/10/a-css3-learning-tool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

