<?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>Interaction Designer Craig Dennis &#187; CSS</title>
	<atom:link href="http://craigmdennis.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://craigmdennis.com</link>
	<description>The portfolio &#38; blog for Craig Dennis, an Interaction Designer based in South East England</description>
	<lastBuildDate>Thu, 23 Feb 2012 14:05:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=220</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>HoverIntent jQuery plugin initiated by a click event</title>
		<link>http://craigmdennis.com/hoverintent-jquery-plugin-initiated-by-a-click-event/</link>
		<comments>http://craigmdennis.com/hoverintent-jquery-plugin-initiated-by-a-click-event/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 22:28:49 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HoverIntent]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://craigmdennis.com/?p=2298</guid>
		<description><![CDATA[Let me start by saying that I am not a developer, I am a designer who dabbles in jQuery and as such my code will probably not be the cleanest or most efficient but it gets the job done. I will also assume you have some basic knowledge of jQuery. View the demo Recently I... <a class="more" href="http://craigmdennis.com/hoverintent-jquery-plugin-initiated-by-a-click-event/">Read more &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://craigmdennis.com/demos/hover-intent"><img class="alignnone size-full wp-image-2320" title="hoverIntent" src="http://uploads.craigmdennis.com/2010/11/hoverIntent.jpg" alt="" width="414" height="150" /></a></p>
<p>Let me start by saying that I am not a developer, I am a designer who dabbles in jQuery and as such my code will probably not be the cleanest or most efficient but it gets the job done.</p>
<p>I will also assume you have some basic knowledge of jQuery.</p>
<p><a class="call-to-action" href="http://craigmdennis.com/demos/hover-intent/" target="_blank">View the demo</a></p>
<p>Recently I had to create a sophisticated jQuery interface initiated by clicking an icon and showing a div then fading it away upon leaving the div. The problem was the shape meant that when a user moved the cursor from the icon to the div they briefly left the confines of the div and as such the div would fade out. This was a problem and the solution seemed to be the <a href="http://cherne.net/brian/resources/jquery.hoverIntent.html" target="_blank">Hover Intent plugin</a> which allows the mouse cursor to leave the div and re-enter it within a certain number of ms (milliseconds) and not fade out the div (or whatever action you have written).</p>
<p>This is great right? Well yeah, but this only works when you hover over an element to begin with. What happens when you want to initiate the initial action on a click instead of on hover? This was my problem.</p>
<h3>My solution:</h3>
<p>So lets set up Hover Intent set up to work on hover with a mega-menu. Below is just the jQuery, you can see the html and CSS <a href="http://craigmdennis.com/demos/hover-intent/" target="_blank">in the demo</a> if you want to or <a href="http://craigmdennis.com/downloads/hover-intent.zip">download the source files here</a>.</p>
<pre>$(document).ready(function(){
$('body').removeClass('no-js'); // Removes the class 'no-js' from the body to let us know javascript is enabled
function slideTheMenuDown() { // This function is called by hover intent 'over:'
$(this).find('.subnav').slideDown('fast'); // Slide the menu down
}

function slideTheMenuUp() { // This function is called by hover intent 'out:'
$(this).find('.subnav').slideUp('fast'); // Slide up the sub menu
}

$('ul.topnav li').hoverIntent({
sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
interval: 100,   // number = milliseconds of polling interval (we want this to be initiated on click rather than hover)
over: slideTheMenuDown,  // function = onMouseOver callback (required)
timeout: 500,   // number = milliseconds delay before onMouseOut function call
out: slideTheMenuUp    // function = onMouseOut callback (required)
})
});</pre>
<p>Now that we have Hover Intent working on hover all we need to do is wrap the function slideTheMenuDown in a click event. When Hover Intent reacts to a hover event, there is no action until the associated click event has triggered (basically until you click nothing happens). The result is no animation until you are hovering over the desired element and are also clicking it. Sweet right?</p>
<p>This is what it looks like</p>
<pre>function slideTheMenuDown() {
    $(this).click(function() { // We wrap the action in a click event
        $(this).find('.subnav').slideDown('fast') // Slide the menu down on click
    });
});</pre>
<p>That&#8217;s it, you&#8217;re done.</p>
<p>I have added a few embellishments such as adding an active class to the parent li so when you hover onto the submenu, the hover state sticks on the top level menu item.</p>
<p><a href="http://www.premiumpixels.com/clean-simple-navigation-menu-psd/">Get the menu style as a psd from Premium Pixels</a></p>
<p><a class="call-to-action" href="http://craigmdennis.com/demos/hover-intent/" target="_blank">View the demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://craigmdennis.com/hoverintent-jquery-plugin-initiated-by-a-click-event/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress, TimThumb &amp; jQuery: Image Hover Effect</title>
		<link>http://craigmdennis.com/wordpress-timthumb-jquery-image-hover-effect/</link>
		<comments>http://craigmdennis.com/wordpress-timthumb-jquery-image-hover-effect/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 16:40:01 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Effect]]></category>
		<category><![CDATA[Greyscale Hover]]></category>
		<category><![CDATA[Hover]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[On-The-Fly Thumbnails]]></category>
		<category><![CDATA[Thumbnail Generation]]></category>
		<category><![CDATA[TimThumb]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://craigmdennis.com/?p=1986</guid>
		<description><![CDATA[This post is about using TimThumb to create an on-the-fly, greyscale image thumbnail of the first image in a post and use jQuery to fade in a colour version on top creating a nice effect. Let me also say that this is not in-depth and is not for beginners as I&#8217;m not going to walk... <a class="more" href="http://craigmdennis.com/wordpress-timthumb-jquery-image-hover-effect/">Read more &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-2104" title="wordpress" src="http://uploads.craigmdennis.com/2010/04/wordpress-420x370.jpg" alt="" width="420" height="370" /></p>
<p>This post is about using TimThumb to create an on-the-fly, greyscale image thumbnail of the first image in a post and use jQuery to fade in a colour version on top creating a nice effect.</p>
<p>Let me also say that this is not in-depth and is not for beginners as I&#8217;m not going to walk you through each step, merely give you an overview.</p>
<p>If you want to see a demo then look at my <a href="http://craigmdennis.com/articles/">homepage</a> as I&#8217;ve used this effect there and on my search &amp; post lists. As the thumbnails are created on-the-fly and not during image upload, you can use this technique anywhere you like! Why there isn&#8217;t a plugin for this I don&#8217;t know.</p>
<p>Things you will need:</p>
<ol>
<li>TimThumb.php</li>
<li><a href="http://www.pixellica.com/web/free-wordpress-script-for-custom-post-images#more-837" target="_blank">Get the Image script</a> (includes a TimThumb.php in a package file)</li>
<li>jQuery</li>
<li>WordPress</li>
</ol>
<p>Put TimThumb.php in your theme folder in /scripts/ (create this folder if it doesn&#8217;t exist)</p>
<p>Follow <a href="http://www.pixellica.com/web/free-wordpress-script-for-custom-post-images#more-837" target="_blank">this</a> tutorial to get TimThumb and Get The Image working in wordpress. It&#8217;s as simple as copying the script to your functions.php file (or create one if you don&#8217;t have one).</p>
<p>Link to jQuery (there is a way to link to the jQuery library that comes with WordPress but I prefer to link to the one hosted on Google)</p>
<p><strong>To view all the code, simply hover over it.</strong></p>
<h3><strong>Link to jQuery</strong></h3>
<p>Add the following to your header template to link to the Google Code hosted jQuery library:</p>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<h3><strong>The PHP</strong></h3>
<p>This goes in your template file</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">
<div id="_mcePaste">&lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;</div>
<div id="_mcePaste" style="padding-left: 30px;">&lt;div class="home-thumb"&gt;</div>
<div id="_mcePaste" style="padding-left: 60px;">&lt;a class="post-thumb-a" href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php echo get_image(150, 306, '2'); ?&gt;&lt;/a&gt;</div>
<div id="_mcePaste" style="padding-left: 60px;">&lt;a class="post-thumb-b" href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php echo get_image(150,306,''); ?&gt;&lt;/a&gt;</div>
<div id="_mcePaste" style="padding-left: 30px;">&lt;/div&gt;</div>
<div id="_mcePaste">&lt;?php endwhile; endif; ?&gt;</div>
</pre>
<p>This should be generally familiar to WordPress people but it&#8217;s saying if there are posts, while there are posts, get the information within the post. More information can be found on the <a href="http://codex.wordpress.org/The_Loop" target="_blank">WordPress Codex about The Loop</a>. The permalink links to the url of the post (can be any link destination though) and inside the link we call the function you should have pasted into your functions file &#8211; get_image(). The arguments are &#8216;height&#8217;, &#8216;width&#8217; and &#8216;filter&#8217;. I have yet to find a list of all the filters supported by TimThumb but for this you&#8217;ll only need filter 2 &#8211; greyscale.</p>
<p>So get_image()  gets the first image in the post and crops it to the dimensions inside the callback (in this case a height of 150px and a width of 306px but you can choose any size that is smaller than the image in the post). The third number is calling a filter from TimThumb which creates a greyscale thumbnail of the image. Then we duplicate this call but remove the &#8217;2&#8242; so we get the full colour thumbnail. We do this so that we can position them one on top of the other and fade one in creating a cool transtion.</p>
<p>The class &#8216;.post-thumb-a&#8217; should be on the link containg the greyscale image &amp; the class &#8216;.post-thumb-b&#8217; goes on the link containing the colour image. This is important as &#8216;.post-thumb-a&#8217; will be placed on top to hide the colour image and will be faded out to reveal the colour image.</p>
<h3>The CSS</h3>
<p>This positions the images and title correctly</p>
<pre>.home-thumb {

<span style="white-space: pre;">	</span>overflow:hidden;

<span style="white-space: pre;">	</span>position:relative;

<span style="white-space: pre;">	</span>width:306px;

<span style="white-space: pre;">	</span>height:150px;

}

a.post-thumb-a img, a.post-thumb-b img {

<span style="white-space: pre;">	</span>position:absolute;<span style="white-space: pre;">	</span>

<span style="white-space: pre;">	</span>top:0;

<span style="white-space: pre;">	</span>left:0;

}

a.post-thumb-a img {

<span style="white-space: pre;">	</span>z-index:10;

}</pre>
<p>What the CSS does is position &#8216;post-thumb-a img&#8217; (the image inside the link) on top (z-index:10;) of post-thumb-b img. This needs to be inside a div as it uses an absolute position to make sure they are pixel perfect overlayed. Make the parent div the same height and width as the thumbnail size you specified in the get_image() callback above.</p>
<p>If you test this now, you should see the greyscale image and not the coloured on &#8212; that&#8217;s because they coloured one is hidden underneath.</p>
<h3>The Javascript</h3>
<p>This goes in the header.php template of your WordPress theme</p>
<pre>&lt;script type="text/javascript"&gt;

jQuery(document).ready(function($){

<span style="white-space: pre;">	</span>$(".home-thumb a img").hover(

<span style="white-space: pre;">		</span>function() {

<span style="white-space: pre;">			</span>$(this).stop().animate({"opacity": "0"}, 800);

<span style="white-space: pre;">			</span>},

<span style="white-space: pre;">		</span>function() {

<span style="white-space: pre;">			</span>$(this).stop().animate({"opacity": "1"}, 800);

<span style="white-space: pre;">			</span>});

});

&lt;/script&gt;</pre>
<p>The Javascript selects &#8216;.home-thumb-a img&#8217; (the greyscale image within the link, the one hiding the coloured image) and sets the opacity to &#8217;1&#8242; until the mouse hovers over it, then change the opacity to &#8217;0&#8242; over the time of 800 ms (1000 ms = 1 second) to reveal the colour image, creating a colour fading effect.</p>
<p>That&#8217;s it, you&#8217;re done. Now have a play around. I&#8217;ve added a title tag in mine.</p>
<p>If I&#8217;ve made a mistake anywhere here please let me know and I&#8217;ll make sure to change it. Any questions and I&#8217;ll be glad to help.</p>
]]></content:encoded>
			<wfw:commentRss>http://craigmdennis.com/wordpress-timthumb-jquery-image-hover-effect/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>CSS, Troubles &amp; More</title>
		<link>http://craigmdennis.com/css-troubles-more/</link>
		<comments>http://craigmdennis.com/css-troubles-more/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 23:36:56 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTTP Error]]></category>
		<category><![CDATA[Loud Music]]></category>
		<category><![CDATA[Margins]]></category>
		<category><![CDATA[Padding]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[Strongly Worded Letter]]></category>
		<category><![CDATA[Visual Editor]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://craigmdennis.com/?p=1236</guid>
		<description><![CDATA[With New Designers coming up rapidly there has been much fretting about who is doing what and who is designing what. With myself and a few others being on an internship at Samsung it has proved hard to keep things consistent. After much arguing through many emails I have decided to defer my vote to... <a class="more" href="http://craigmdennis.com/css-troubles-more/">Read more &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p>With New Designers coming up rapidly there has been much fretting about who is doing what and who is designing what. With myself and a few others being on an internship at Samsung it has proved hard to keep things consistent.</p>
<p>After much arguing through many emails I have decided to defer my vote to someone else as it&#8217;s getting heated. Just need someone to make a creative decision who is higher up in the hierarchy than we are.</p>
<p>Forgetting all of that stuff, I have redesigned my website, business card and all pdf documents and updated my &#8216;brand&#8217; since doing that for the final degree exhibition. I changed the colour to 100% Magenta instead of orange but kept the same font The portfolio section is now up with proper descriptions, pictures and styling (with some more projects to come when I get a chance).</p>
<p>My business card can be seen below and yes I am aware that the back of the card has the wrong corners rounded in the image.</p>
<p><a href="http://uploads.craigmdennis.com/2009/07/2009-07-02_BusinessCard.jpg"><img class="alignnone size-full wp-image-1239" title="Busniness Card" src="http://uploads.craigmdennis.com/2009/07/2009-07-02_BusinessCard.jpg" alt="Busniness Card" width="356" height="356" /></a></p>
<p>While at Samsung I noticed that my new website design did not look correct in IE6 (no surprise there then) so I spent some time correcting some CSS problems. No sooner than I had done that than I tried it in Safari and it failed even more to display correctly.<span id="more-1236"></span></p>
<p>After several hours trying to figure out what the problem was, changing (and improving) my CSS stylesheet I discovered that even though I zero&#8217;d all margins at the start of the CSS by:</p>
<pre>* {margin:0px; padding:0px}</pre>
<p>Safari is a bitch and does not recognise that. So after several hours of trying, finally declaring the padding and margins as 0 for ul and li elements as well as entire divs, the formatting magically came into alignment in Safari.</p>
<p>After doing all that, feeling like I needed to vent some of my frustration and being British I wanted to write a strongly worded letter to Mr. Jobs. Instead I am blogging about it. This in itself proved more difficult than first anticipated as when I logged into Worpress, the visual text editor for the post screen had gone and all the text was coming out in white! After a quick Google and a re-install of WordPress 2.8 the editor came back and I can see what I&#8217;m writing now.</p>
<p>I have just received an HTTP error while uploading my business card image. Seriously what is going on with the internet tonight?</p>
<p>Now the reason I am blogging at this late hour and not in bed, asleep in preparation for work tomorrow is simple&#8230; There are people in my house who I don&#8217;t know, playing very loud music. I hope tomorrow is a better day.</p>
]]></content:encoded>
			<wfw:commentRss>http://craigmdennis.com/css-troubles-more/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>8 CSS Fonts That I Should Know?</title>
		<link>http://craigmdennis.com/8-css-fonts-that-i-should-know/</link>
		<comments>http://craigmdennis.com/8-css-fonts-that-i-should-know/#comments</comments>
		<pubDate>Mon, 12 May 2008 23:16:23 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[Typeface]]></category>

		<guid isPermaLink="false">http://craigmdennis.com/?p=520</guid>
		<description><![CDATA[Here is a link that shows 8 fonts that should be used in CSS but aren&#8217;t. They are long, lost and forgotten typefaces that actually&#8230; should come in handy in web design. Have a look at the post on 3point7designs. They show each font&#8217;s availability on Mac and PC&#8230; No Linux info though, sorry all... <a class="more" href="http://craigmdennis.com/8-css-fonts-that-i-should-know/">Read more &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.3point7designs.com/articles/2008/05/08/8-fonts-you-probably-dont-use-in-css-but-should/">Here</a> is a link that shows 8 fonts that should be used in CSS but aren&#8217;t. They are long, lost and forgotten typefaces that actually&#8230; should come in handy in web design. Have a look at the post on <a href="http://www.3point7designs.com/" target="_blank">3point7designs</a>. They show each font&#8217;s availability on Mac and PC&#8230; No Linux info though, sorry all you open-sourcers.</p>
]]></content:encoded>
			<wfw:commentRss>http://craigmdennis.com/8-css-fonts-that-i-should-know/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

