<?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>Zenovation's Blog &#187; css</title>
	<atom:link href="http://zenovations.com/blog/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://zenovations.com/blog</link>
	<description>A blog about web design, programming, hosting, and virtualmin hacks</description>
	<lastBuildDate>Mon, 16 Jan 2012 15:01:54 +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>Dealing with CSS unit conversions in jQuery (px to em to percentages)</title>
		<link>http://zenovations.com/blog/2012/01/dealing-with-css-unit-conversions-in-jquery-px-to-em-to-percentages/</link>
		<comments>http://zenovations.com/blog/2012/01/dealing-with-css-unit-conversions-in-jquery-px-to-em-to-percentages/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 14:59:01 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=267</guid>
		<description><![CDATA[I spent some time working on a plugin to convert px to em and percentages for the upcoming Wordspot site. The problem lies in the fact that measurements are based on the element they are attached to. Thus, to convert any CSS property (i.e. &#8220;5em&#8221; or &#8220;20%&#8221;) to pixels, one must determine what the relative [...]]]></description>
			<content:encoded><![CDATA[<p>I spent some time working on a plugin to convert px to em and percentages for the upcoming <a href="http://www.wordspot.org">Wordspot</a> site. </p>
<p>The problem lies in the fact that measurements are based on the element they are attached to. Thus, to convert any CSS property (i.e. &#8220;5em&#8221; or &#8220;20%&#8221;) to pixels, one must determine what the relative height of a single line of text is in pixels.</p>
<p>This tool creates an invisible child element, measures a single line of text, and uses that for measurements.</p>
<p>Thus, to convert 90% (or any measurement, for that matter) to pixels, you could do the following:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p267code3'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2673"><td class="code" id="p267code3"><pre class="javascript" style="font-family:monospace;">   <span style="color: #003366; font-weight: bold;">var</span> borderRadiusPixels <span style="color: #339933;">=</span> $.<span style="color: #660066;">UnitConverter</span>.<span style="color: #660066;">px</span><span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mydiv'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'border-top-left-radius'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><a href="/blog/misc/jquery.unitconverter.js.txt" title="UnitConverter source code">Here&#8217;s the source</a>.</p>
<p>For more advanced operations, you can do things like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p267code4'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2674"><td class="code" id="p267code4"><pre class="javascript" style="font-family:monospace;">   <span style="color: #006600; font-style: italic;">// create a new unit conversion</span>
   <span style="color: #003366; font-weight: bold;">var</span> measurement <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> $.<span style="color: #660066;">UnitConverter</span><span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mydiv'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #006600; font-style: italic;">// load a value to be examined</span>
   measurement.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mydiv'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'border-left-width'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #006600; font-style: italic;">// add 10% to the height</span>
   measurement.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'10%'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #006600; font-style: italic;">// convert the measurement to various output types</span>
   <span style="color: #003366; font-weight: bold;">var</span> pxs <span style="color: #339933;">=</span> measurement.<span style="color: #660066;">px</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #003366; font-weight: bold;">var</span> ems <span style="color: #339933;">=</span> measurement.<span style="color: #660066;">convert</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'em'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #003366; font-weight: bold;">var</span> pct <span style="color: #339933;">=</span> measurement.<span style="color: #660066;">convert</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'%'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #006600; font-style: italic;">// determine what the measurement would be in another element (i.e. with a different line height)</span>
   <span style="color: #003366; font-weight: bold;">var</span> clonePxs <span style="color: #339933;">=</span> measurement.<span style="color: #660066;">clone</span><span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#nudderElement'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">px</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Hopefully this will give you a good head start on conquering similar issues, without having to invent any wheels!</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2012/01/dealing-with-css-unit-conversions-in-jquery-px-to-em-to-percentages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drawing a quote box with css</title>
		<link>http://zenovations.com/blog/2011/11/drawing-a-quote-box-with-css/</link>
		<comments>http://zenovations.com/blog/2011/11/drawing-a-quote-box-with-css/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 20:08:33 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=263</guid>
		<description><![CDATA[I recently searched El Goog for a way to drawing a quote box with only css and came across several ideas. Nicholas Gallagher had the simplest, and most compatible approach found during my quick surf, in his article titled &#8220;Pure CSS speech bubbles.&#8221; Essentially, his quote box, or speech bubble, came down to the following simple [...]]]></description>
			<content:encoded><![CDATA[<p>I recently searched El Goog for a way to drawing a quote box with only css and came across several ideas. Nicholas Gallagher had the simplest, and most compatible approach found during my quick surf, in his article titled &#8220;<a href="http://nicolasgallagher.com/pure-css-speech-bubbles/demo/">Pure CSS speech bubbles</a>.&#8221;</p>
<p>Essentially, his quote box, or speech bubble, came down to the following simple CSS code (there is no HTML or JS involved) and even works in IE; nice!</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p263code6'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2636"><td class="code" id="p263code6"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.triangle-border</span>.<span style="color: #000000; font-weight: bold;">left</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
.triangle-<span style="color: #000000; font-weight: bold;">border</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#5A8F00</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333333</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1em</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">3em</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2011/11/drawing-a-quote-box-with-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get elements by CSS class name in javascript</title>
		<link>http://zenovations.com/blog/2010/06/get-elements-by-css-class-name-in-javascript/</link>
		<comments>http://zenovations.com/blog/2010/06/get-elements-by-css-class-name-in-javascript/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 19:59:59 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[code clips]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=195</guid>
		<description><![CDATA[Dustin Diaz wrote a nice, efficient version of getElementByClassName(), which searches HTML elements and retrieves all the items with a given CSS class specified. Of course, if you use a lib like extjs, jQuery, et al, then you have no need of this. But if you&#8217;re trying to hack out a greasemonkey script or insert [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dustindiaz.com">Dustin Diaz</a> wrote a nice, efficient version of getElementByClassName(), which searches HTML elements and retrieves all the items with a given CSS class specified.</p>
<p>Of course, if you use a lib like extjs, jQuery, et al, then you have no need of this. But if you&#8217;re trying to hack out a greasemonkey script or insert some minimalist code, <a href="http://www.dustindiaz.com/getelementsbyclass/">here it is</a>.</p>
<p>And here it is, for my own archives:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p195code9'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1959"><td class="code" id="p195code9"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getElementsByClass<span style="color: #009900;">&#40;</span>searchClass<span style="color: #339933;">,</span>node<span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> classElements <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> node <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span>
		node <span style="color: #339933;">=</span> document<span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> tag <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span>
		tag <span style="color: #339933;">=</span> <span style="color: #3366CC;">'*'</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> els <span style="color: #339933;">=</span> node.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> elsLen <span style="color: #339933;">=</span> els.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> pattern <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;(^|<span style="color: #000099; font-weight: bold;">\\</span>s)&quot;</span><span style="color: #339933;">+</span>searchClass<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;(<span style="color: #000099; font-weight: bold;">\\</span>s|$)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> j <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> elsLen<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> pattern.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>els<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			classElements<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> els<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			j<span style="color: #339933;">++;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> classElements<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here&#8217;s another alternative I found on <a href="http://daniel.glazman.free.fr/weblog/">Glazblog</a>, using xpath to search the document:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p195code10'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p19510"><td class="code" id="p195code10"><pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">getElementByClassName</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>needle<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> xpathResult <span style="color: #339933;">=</span> document.<span style="color: #660066;">evaluate</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'//*[@class = needle]'</span><span style="color: #339933;">,</span> document<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> outArray <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>outArray<span style="color: #009900;">&#91;</span>outArray.<span style="color: #660066;">length</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> xpathResult.<span style="color: #660066;">iterateNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> outArray<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I don&#8217;t really know which is more efficient, though I suspect the xpath search could be taxing in very large documents. I&#8217;m positive, based on IE&#8217;s fake implementation of key/value pairs in the DOM, that they both suck in IE, even if you specify a specific tag type to search. Obviously, providing a node makes the regular expression search faster, by virtue of having less content to parse.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2010/06/get-elements-by-css-class-name-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Great Compilation of CSS Techniques</title>
		<link>http://zenovations.com/blog/2009/08/great-compilation-of-css-techniques/</link>
		<comments>http://zenovations.com/blog/2009/08/great-compilation-of-css-techniques/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 16:09:55 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/2009/08/great-compilation-of-css-techniques/</guid>
		<description><![CDATA[This compilation is awesome, covering things like fluid horizontal and vertical layouts, sprites, and many other excellent techniques for CSS: http://www.smashingmagazine.com/2009/07/20/50-new-css-techniques-for-your-next-web-design/]]></description>
			<content:encoded><![CDATA[<p>This compilation is awesome, covering things like fluid horizontal and vertical layouts, sprites, and many other excellent techniques for CSS: http://www.smashingmagazine.com/2009/07/20/50-new-css-techniques-for-your-next-web-design/</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/08/great-compilation-of-css-techniques/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

