<?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>WordPress Hacks &#187; CSS Techniques</title>
	<atom:link href="http://wphacks.com/tag/css-techniques/feed/" rel="self" type="application/rss+xml" />
	<link>http://wphacks.com</link>
	<description>WordPress Themes, Plugins, Hacks, Tutorials, and more!</description>
	<lastBuildDate>Thu, 02 Feb 2012 15:20:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How To: Prevent Images from Being to Large</title>
		<link>http://wphacks.com/how-to-prevent-images-from-being-to-large/</link>
		<comments>http://wphacks.com/how-to-prevent-images-from-being-to-large/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 17:09:51 +0000</pubDate>
		<dc:creator>Kyle Eslick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS Techniques]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Wordpress Images]]></category>
		<category><![CDATA[WordPress Themes]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=1904</guid>
		<description><![CDATA[Have you ever had an image show up on your website which is to large, causing problems for your WordPress theme?   This is especially common for WordPress blogs that have multiple authors, where some authors or guest posters may not know how big they can make the images. Fixing this is incredibly easy with this [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had an image show up on your website which is to large, causing problems for your WordPress theme?   This is especially common for WordPress blogs that have multiple authors, where some authors or guest posters may not know how big they can make the images.</p>
<p>Fixing this is incredibly easy with this CSS hack!    All you need to do is take the following code and place it in your stylesheet, setting a maximum width for your images:</p>
<p><code>.postarea img {<br />
max-width: 500px;<br />
height: auto;<br />
}</code></p>
<p>In the above code snippet, you&#8217;ll want to replace postarea with whatever div ID or CLASS your theme uses for the content.   You can also adjust the 500px to the maximum width you&#8217;d like for your images to be.</p>
<p><strong>Note:</strong> This hack may not work on some versions of Internet Explorer.</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=1904&type=feed" alt="" /><p>You are reading <a href="http://wphacks.com/how-to-prevent-images-from-being-to-large/">How To: Prevent Images from Being to Large</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-prevent-images-from-being-to-large/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>CSS Techniques: Using Sliding Doors with WordPress Navigation</title>
		<link>http://wphacks.com/sliding-doors-wordpress-navigation-css-technique/</link>
		<comments>http://wphacks.com/sliding-doors-wordpress-navigation-css-technique/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 06:00:54 +0000</pubDate>
		<dc:creator>Jean-Baptiste Jung</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[CSS Techniques]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress How-To]]></category>
		<category><![CDATA[WordPress Menu]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=642</guid>
		<description><![CDATA[The <em>sliding doors</em> CSS hack allows you to create sophisticated tabs for your navigation bar. Sadly, Wordpress core functions <em>wp_list_pages()</em> and <em>wp_list_categories()</em> doesn't allow you to add the required <em>span</em> tag to use this technique.
We are goind to see how to proceed in order to use <em>sliding doors</em> in our Wordpress theme.]]></description>
			<content:encoded><![CDATA[<p>This <em>sliding doors</em> CSS hack allows you to create sophisticated tabs for your navigation bar. Sadly, WordPress core functions <em>wp_list_pages()</em> and <em>wp_list_categories()</em> don&#8217;t allow you to add the required <em>span</em> tag to use this technique.</p>
<p>We are going to see how to proceed in order to use <em>sliding doors</em> in our WordPress theme.</p>
<h2>Sliding doors, why?</h2>
<p>There&#8217;s many articles available on the web about the <em>sliding doors</em> technique, so I&#8217;m not going to talk a lot about it. For people who don&#8217;t already know this famous hack, here&#8217;s a quick example.</p>
<p>Let&#8217;s build a typical navigation list:</p>
<p><code>&lt;ul id="nav"&gt;<br />
&lt;li&gt;&lt;a href="#"&gt;link n°1&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#"&gt;link n°2&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#"&gt;link n°3&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;</code></p>
<p>If we apply, via CSS, background images to our links in order to make this menu prettier, we&#8217;ll quickly see a big problem: We must add a fixed width to the links, otherwise the image will be truncated if the link is too short, or the link will overflow the image if its width is too long.</p>
<p>That&#8217;s why <em>sliding doors</em> are very useful: We just have to add a <em>span</em> element inside the link, and then, in our CSS, assign a different background image to both the span element and the link.</p>
<p><code>&lt;ul id="nav"&gt;<br />
&lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;link n°1&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;link n°2&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;link n°3&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;</code></p>
<p>Our CSS should look like this:</p>
<p><code>#nav a, #nav a:visited {<br />
display:block;<br />
}<br />
#nav a:hover, #nav a:active {<br />
background:url(images/tab-right.jpg) no-repeat 100% 1px;<br />
float:left;<br />
}<br />
#nav a span {<br />
float:left;<br />
display:block;<br />
}<br />
#nav a:hover span {<br />
float:left;<br />
display:block;<br />
background: url(images/tab-left.jpg) no-repeat 0 1px;<br />
}</code></p>
<p><em>Please note, as this is only an example, the CSS above isn&#8217;t complete and only shows how to apply the sliding doors hack.</em></p>
<p>You can see a live demo of a navigation menu which uses this technique on my blog <a href="http://www.catswhocode.com">here.</a></p>
<p><img src="http://www.lyxia.org/blog/wp-content/uploads/2008/06/wordpress-sliding-doors-menu.jpg" alt="Wordpress sliding doors" /></p>
<h2>Using the sliding doors hack within WordPress</h2>
<p>I saw many blog posts where some users told you to modify WordPress core in order to apply this technique. Personally, I never really liked this idea: First, the WordPress core wasn&#8217;t made for being modified. And secondly, if you do, when you&#8217;ll upgrade your WP version, you&#8217;ll have to re-modify the core. Not user friendly at all!</p>
<p>Instead of this, let&#8217;s use a regular expression, by using the php <em>preg_replace()</em> function. We are going to get our pages (or categories) without displaying it, and passing it as a parameter to <em>preg_replace()</em>. The two remaining parameters will be, of course, our regular expression: The pattern we&#8217;re looking for, and this pattern&#8217;s replacement.</p>
<p>To create this menu, paste the following code instead of the <em>wp_list_pages()</em> (or <em>wp_list_categories()</em>) function in the <em>header.php</em> of your WordPress theme.</p>
<p>To list your pages:</p>
<p><code>&lt;ul id="nav"&gt;<br />
&lt;li&gt;&lt;a href="&lt;?php echo get_option('home'); ?&gt;/"&gt;&lt;span&gt;Home&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;?php echo preg_replace('@\&lt;li([^&gt;]*)&gt;\&lt;a([^&gt;]*)&gt;(.*?)\&lt;\/a&gt;@i', '&lt;li$1&gt;&lt;a$2&gt;&lt;span&gt;$3&lt;/span&gt;&lt;/a&gt;', wp_list_pages('echo=0&amp;orderby=name&amp;exclude=181&amp;title_li=&amp;depth=1')); ?&gt;<br />
&lt;/ul&gt;</code></p>
<p>To list your categories:</p>
<p><code>&lt;ul id="nav"&gt;<br />
&lt;li&gt;&lt;a href="&lt;?php echo get_option('home'); ?&gt;/"&gt;&lt;span&gt;Home&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;?php echo preg_replace('@\&lt;li([^&gt;]*)&gt;\&lt;a([^&gt;]*)&gt;(.*?)\&lt;\/a&gt;@i', '&lt;li$1&gt;&lt;a$2&gt;&lt;span&gt;$3&lt;/span&gt;&lt;/a&gt;', wp_list_categories('echo=0&amp;orderby=name&amp;exclude=181&amp;title_li=&amp;depth=1')); ?&gt;<br />
&lt;/ul&gt;</code></p>
<p>Right now, your new menu is ready. You just have to make it sexy with CSS. Have fun! <img src='http://wphacks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=330&type=feed" alt="" /><p>You are reading <a href="http://wphacks.com/sliding-doors-wordpress-navigation-css-technique/">CSS Techniques: Using Sliding Doors with WordPress Navigation</a>  © 2008 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/sliding-doors-wordpress-navigation-css-technique/feed/</wfw:commentRss>
		<slash:comments>60</slash:comments>
		</item>
	</channel>
</rss>

