<?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>DivitoDesign &#187; Frank Verhoeven</title>
	<atom:link href="http://divitodesign.com/author/frans/feed/" rel="self" type="application/rss+xml" />
	<link>http://divitodesign.com</link>
	<description>Articles, Tutorials and Resources for the Webdesigner</description>
	<lastBuildDate>Fri, 07 Oct 2011 18:47:18 +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>The MouseClick Effect With CSS</title>
		<link>http://divitodesign.com/css/the-mouseclick-effect-with-css/</link>
		<comments>http://divitodesign.com/css/the-mouseclick-effect-with-css/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 00:54:32 +0000</pubDate>
		<dc:creator>Frank Verhoeven</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.divitodesign.com/?p=125</guid>
		<description><![CDATA[In this article you will learn about the MouseClick effect and you&#8217;ll learn how to use this in your own website or blog. It isn&#8217;t too hard to understand and nice to know. What is a MouseClick effect? The MouseClick effect is everything you will see when you click on a link item. In JavaScript, [...]]]></description>
			<content:encoded><![CDATA[<p>In this article you will learn about the <strong>MouseClick effect</strong> and you&#8217;ll learn how to use this in your own website or blog. It isn&#8217;t too hard to understand and nice to know.</p>
<h2>What is a MouseClick effect?</h2>
<p>The MouseClick effect is everything you will see when you click on a link item. In JavaScript, this is a piece of cake when you use a property like <em>onMouseClick</em> or <em>onMouseDown</em>. Today, we will try to obtain the same effect using CSS.</p>
<p>We have to style the <strong>a:active selector</strong> to get the desired effect.<br />
<span id="more-125"></span></p>
<h2>An example</h2>
<p>We will begin with a normal, unstyled link. That link has a blue color and a underline, a red color when you have selected the link, a purple color if you have already visited the link. And when you roll your mouse over the link, the underline will be removed.</p>
<p>Just a normal link tag:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="html"><span class="html-anchor-element">&lt;a&gt;</span>Link<span class="html-anchor-element">&lt;/a&gt;</span></span></pre>
</div>
<p>And now the CSS:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre>
<pre><span class="css">a {
<span class="css-property">color<span class="css-selector">:</span><span class="css-value"> #2665aa</span></span>;
<span class="css-property">text-decoration<span class="css-selector">:</span><span class="css-value"> underline</span></span>;
}
a:hover {
<span class="css-property">text-decoration<span class="css-selector">:</span><span class="css-value"> none</span></span>;
}
a:active {
<span class="css-property">color<span class="css-selector">:</span><span class="css-value"> #666666</span></span>;
}</span></pre>
</div>
<p>As you can see, it is really simple to change everything via your CSS. Most likely, you already know this. If not, you should read some other articles regarding css which can be found in the <a href="/tag/css">CSS tag</a>. Some more in-depth information follows next.</p>
<h2>The MouseClick example</h2>
<p>To give this technique a real example we use an un-ordered list with preloaded images. Take a look below.</p>
<p>First some basic html, a normal un-ordered list:</p>
<h3>HTML:</h3>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
</pre>
<pre><span class="html"><span class="html-other-element">&lt;ul&gt;</span>
	<span class="html-other-element">&lt;li&gt;</span><span class="html-anchor-element">&lt;a&gt;</span>Item<span class="html-anchor-element">&lt;/a&gt;</span><span class="html-other-element">&lt;/li&gt;</span>
	<span class="html-other-element">&lt;li&gt;</span><span class="html-anchor-element">&lt;a&gt;</span>Item<span class="html-anchor-element">&lt;/a&gt;</span><span class="html-other-element">&lt;/li&gt;</span>
	<span class="html-other-element">&lt;li&gt;</span><span class="html-anchor-element">&lt;a&gt;</span>Item<span class="html-anchor-element">&lt;/a&gt;</span><span class="html-other-element">&lt;/li&gt;</span>
	<span class="html-other-element">&lt;li&gt;</span><span class="html-anchor-element">&lt;a&gt;</span>Item<span class="html-anchor-element">&lt;/a&gt;</span><span class="html-other-element">&lt;/li&gt;</span>
<span class="html-other-element">&lt;/ul&gt;</span></span></pre>
</div>
<h3>CSS:</h3>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
</pre>
<pre><span class="css">ul {
<span class="css-property">list-style<span class="css-selector">:</span><span class="css-value"> none</span></span>;
}
ul li {
<span class="css-property">display<span class="css-selector">:</span><span class="css-value"> inline</span></span>;
<span class="css-property">margin<span class="css-selector">:</span><span class="css-value"> 0</span></span>;
<span class="css-property">padding<span class="css-selector">:</span><span class="css-value"> 0</span></span>;
}
ul li a {
<span class="css-property">float<span class="css-selector">:</span><span class="css-value"> left</span></span>;
<span class="css-property">display<span class="css-selector">:</span><span class="css-value"> block</span></span>;
<span class="css-property">width<span class="css-selector">:</span><span class="css-value"> 81px</span></span>;
<span class="css-property">height<span class="css-selector">:</span><span class="css-value"> 26px</span></span>;
<span class="css-property">color<span class="css-selector">:</span><span class="css-value"> #333</span></span>;
<span class="css-property">text-align<span class="css-selector">:</span><span class="css-value"> center</span></span>;
<span class="css-property">background-image<span class="css-selector">:</span><span class="css-value"> url(NavigationBackground.png)</span></span>;
<span class="css-property">background-repeat<span class="css-selector">:</span><span class="css-value"> none</span></span>;
<span class="css-property">background-position<span class="css-selector">:</span><span class="css-value"> 0 0</span></span>;
}
ul li a:hover {
<span class="css-property">background-position<span class="css-selector">:</span><span class="css-value"> 0 -26px</span></span>;
<span class="css-property">color<span class="css-selector">:</span><span class="css-value"> #cccccc</span></span>;
}
ul li a:active {
<span class="css-property">background-position<span class="css-selector">:</span><span class="css-value"> 0 -52px</span></span>;
<span class="css-property">color<span class="css-selector">:</span><span class="css-value"> #cccccc</span></span>;
}</span></pre>
</div>
<p>You&#8217;re might ask yourself this question: Where are the different background images?</p>
<p>We actually use only one image to split normal background, hover background and MouseClick background. It is all about positioning that image to show the right background in the right place. The image can be found below:</p>
<p><img src="http://www.divitodesign.com/wp-content/uploads/2008/06/navigationbackground.png" alt="Navigation Background" /><br />
In the CSS provided to you in the MouseClick example, you will see the different <strong>a:selectors</strong> getting styled. With the <em>background-position</em> our image gets positioned.</p>
<p>If you want to see a real example regarding the MouseClick effect, please visit the following link.</p>
<p><a href="http://www.divitodesign.com/dd-articles/mouse-click/">MouseClick effect &#8211; Example</a></p>
<h2>Conclusion</h2>
<p>This effect is a nice little addition to your website, which is easy to use. If you have any more questions, you could contact me via the <a href="#respond">comments</a>.</p>
<p>Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://divitodesign.com/css/the-mouseclick-effect-with-css/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

