<?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>Andy Weigel &#187; css</title>
	<atom:link href="http://andyweigel.com/blog/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://andyweigel.com/blog</link>
	<description>Web Development Tutorials</description>
	<lastBuildDate>Thu, 12 Aug 2010 18:53:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Style WordPress Titles Based on Number of Letters</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/style-wordpress-titles-based-on-number-of-letters/56</link>
		<comments>http://andyweigel.com/blog/wordpress-how-tos/style-wordpress-titles-based-on-number-of-letters/56#comments</comments>
		<pubDate>Wed, 08 Jul 2009 20:11:50 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Wordpress How-To's]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://andyweigel.com/blog/?p=56</guid>
		<description><![CDATA[A common problem that I&#8217;ve encountered &#8211; how to control dynamic text based on how long it is. In this case I had titles ranging from 10 characters to 25 characters &#8211; this includes spaces. The goal is to make them centered regardless of how many letters and spaces are in the title. Here is [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem that I&#8217;ve encountered &#8211; <strong>how to control dynamic text based on how long it is</strong>. In this case I had titles ranging from 10 characters to 25 characters &#8211; this includes spaces. The goal is to make them centered regardless of how many letters and spaces are in the title.</p>
<p><strong>Here is an example of one of the shorter titles I was given:</strong><br />
	    <img src="http://andyweigel.com/images/single-line-title.jpg" width="455" height="111" alt="single-line-title" /></p>
<p><strong>Here is an example of one of the longer titles I was given:</strong><br />
	    <img src="http://andyweigel.com/images/double-line-title.jpg" width="460" height="114" />		</p>
<p>A series of quick if/else statements and use of the strlen function in PHP allows me to assign different classes depending on the length of the dynamic title. I figured out, based on the CSS on the H1 class, that 14 was my magic number.</p>
<p><strong>Here&#8217;s the quick snippet of code I used:</strong></p>
<pre class="php">
$title <span class="phpOperator">=</span> $post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>post_title<span class="phpText">;</span>
$char_title <span class="phpOperator">=</span> <span class="phpFunction">strlen</span><span class="phpOperator">(</span>$title<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span>$char_title <span class="phpOperator">&gt;</span> 14<span class="phpOperator">)</span> <span class="phpOperator">{</span>$header_style <span class="phpOperator">=</span> <span class="phpString">"double"</span><span class="phpText">;</span><span class="phpOperator">}</span>
<span class="phpKeyword">
else </span><span class="phpOperator">{</span>$header_style <span class="phpOperator">=</span> <span class="phpString">"single"</span><span class="phpText">;</span><span class="phpOperator">}</span></pre>
<p>I grab the post title using common WordPress calls and make it into the $title variable. The I use the strlen function to determine the number of characters (including spaces) in the title. If it&#8217;s greater than 14, it assigns the $header_style variable the class &#8220;double&#8221; or else it assigns it the &#8220;single&#8221; class.</p>
<p><strong>Here is how I used it within the WordPress loop:</strong></p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="phpKeyword"> if </span><span class="phpOperator">(</span><span class="htmlText">have_posts</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">:</span><span class="phpKeyword"> while </span><span class="phpOperator">(</span><span class="htmlText">have_posts</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">:</span><span class="htmlText"> the_post</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span> <span class="phpFunction">echo</span> $header_style <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span></span>&quot;</span>&gt;<span class="htmlOtherTag">&lt;h2&gt;</span><span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> the_title</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span><span class="htmlOtherTag">&lt;/h2&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="phpKeyword"> endwhile<span class="phpText">;</span></span><span class="phpKeyword"> endif<span class="phpText">;</span></span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Hopefully you&#8217;ve found this quick tutorial valuable. <a href="contact.php">Contact me</a> if you have any questions or would do it a different way. There&#8217;s 1,001 ways to do everything &#8211; that&#8217;s why I love coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://andyweigel.com/blog/wordpress-how-tos/style-wordpress-titles-based-on-number-of-letters/56/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dropshadow on Text Using Absolute Positioning</title>
		<link>http://andyweigel.com/blog/css-tricks/dropshadow-on-text-using-absolute-positioning/36</link>
		<comments>http://andyweigel.com/blog/css-tricks/dropshadow-on-text-using-absolute-positioning/36#comments</comments>
		<pubDate>Wed, 08 Jul 2009 18:55:38 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[CSS Tricks]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://andyweigel.com/blog/?p=36</guid>
		<description><![CDATA[Here&#8217;s a quick bit of CSS and HTML to achieve a simple dropshadow on text that uses abosolute positioning. This would work great for titles in WordPress. You can adjust the top and left positioning of the .bottom class depending on the offset of dropshadow you want. Here&#8217;s My Test Here&#8217;s My Test Here&#8217;s the [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick bit of CSS and HTML to achieve a simple dropshadow on text that uses abosolute positioning. This would work great for titles in WordPress. You can adjust the top and left positioning of the .bottom class depending on the offset of dropshadow you want.</p>
<p><span id="more-36"></span></p>
<div class="box">
<div class="top">
<h1>Here&#8217;s My Test</h1>
</div>
<div class="bottom">
<h1>Here&#8217;s My Test</h1>
</div>
</div>
<p><strong>Here&#8217;s the CSS for the output above:</strong> </p>
<pre class="css"> &lt;style type=<span class="cssString">"text/css"</span>&gt;
<span class="cssSelector">.box {</span>
<span class="cssProperty">position</span><span class="cssRest">:</span><span class="cssValue">relative</span><span class="cssRest">;</span>
<span class="cssProperty">background-color</span><span class="cssRest">:</span><span class="cssValue">#666</span><span class="cssRest">;</span>
<span class="cssProperty">height</span><span class="cssRest">:</span><span class="cssValue">75px</span><span class="cssRest">;</span>
<span class="cssProperty">width</span><span class="cssRest">:</span><span class="cssValue">400px</span><span class="cssRest">;</span>
<span class="cssProperty">overflow</span><span class="cssRest">:</span><span class="cssValue">hidden</span><span class="cssRest">;</span>
<span class="cssProperty">padding</span><span class="cssRest">:</span><span class="cssValue">10px</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">.box h1 {</span>
<span class="cssProperty">font-size</span><span class="cssRest">:</span><span class="cssValue">36px</span><span class="cssRest">;</span>
<span class="cssProperty">text-transform</span><span class="cssRest">:</span><span class="cssValue">uppercase</span><span class="cssRest">;</span>
<span class="cssProperty">font-family</span><span class="cssRest">:</span><span class="cssValue">Verdana, Geneva, sans-serif</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">.top {</span>
<span class="cssProperty">color</span><span class="cssRest">:</span><span class="cssValue">#FFF</span><span class="cssRest">;</span>
<span class="cssProperty">position</span><span class="cssRest">:</span><span class="cssValue">absolute</span><span class="cssRest">;</span>
z-index:1;
<span class="cssSelector">}</span>
<span class="cssSelector">.bottom {</span>
<span class="cssProperty">position</span><span class="cssRest">:</span><span class="cssValue">absolute</span><span class="cssRest">;</span>
<span class="cssProperty">color</span><span class="cssRest">:</span><span class="cssValue">#333</span><span class="cssRest">;</span>
<span class="cssProperty">top</span><span class="cssRest">:</span><span class="cssValue">11px</span><span class="cssRest">;</span>
<span class="cssProperty">left</span><span class="cssRest">:</span><span class="cssValue">11px</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
&lt;/style&gt;
</pre>
<p> Here&#8217;s the HTML for the output above: </p>
<pre class="html"> <span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;box&quot;</span>&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;top&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;h1&gt;</span>Here&#039;s My Test<span class="htmlOtherTag">&lt;/h1&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;bottom&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;h1&gt;</span>Here&#039;s My Test<span class="htmlOtherTag">&lt;/h1&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
</pre>
<p>Hopefully you&#8217;ve found this quick tutorial valuable. <a href="contact.php">Contact me</a> if you have any questions or would do it a different way. There&#8217;s 1,001 ways to do everything &#8211; that&#8217;s why I love coding.</p>
<hr/>
]]></content:encoded>
			<wfw:commentRss>http://andyweigel.com/blog/css-tricks/dropshadow-on-text-using-absolute-positioning/36/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
