<?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>The Filipino Web Designer &#187; CSS</title>
	<atom:link href="http://filipinowebdesigner.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://filipinowebdesigner.com</link>
	<description>A half-geek, half-artist's creatively nerdy journal on design and blogging</description>
	<lastBuildDate>Mon, 24 Aug 2009 08:31:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Look, ma! No Javascript!</title>
		<link>http://filipinowebdesigner.com/2007/02/26/look-ma-no-javascript/</link>
		<comments>http://filipinowebdesigner.com/2007/02/26/look-ma-no-javascript/#comments</comments>
		<pubDate>Mon, 26 Feb 2007 05:44:02 +0000</pubDate>
		<dc:creator>Gail</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Guides]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://filipinowebdesigner.com/2007/02/26/look-ma-no-javascript/</guid>
		<description><![CDATA[First of all, I’d like to apologize (again!) for my lack of updates. I know I promised you guys new themes. Believe me, I’m working on them on my spare time. Unfortunately, spare time is a luxury for me these days. So, to make up for it, allow me to give you a short tutorial [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, I’d like to apologize (again!) for my lack of updates. I know I promised you guys new themes. Believe me, I’m working on them on my spare time. Unfortunately, spare time is a luxury for me these days.</p>
<p>So, to make up for it, allow me to give you a short tutorial on creating mouse-over graphics without using Javascripts. I’ve seen this effect in action through sites featured in CSS galleries. And frankly, I had some difficulty finding a tutorial on them—maybe because I just don’t know which keywords to use. Hehe</p>
<p>If you’ve been reading <a href="http://kutitots.com">my personal blog</a>, you’ll notice that I recently did a design make-over. I kept the mouse-over effect, but this time, I used CSS for it—not Javascript.</p>
<p>You’re probably used to seeing simple mouse-over effects <a href="#">like this</a>. It changes color when your mouse is over it. This is a simple effect, and you can even dress it up a bit by putting a background image behind it or something. But what if you wanted to use some fancy font for your link? A fancy font that isn’t available in all computers?</p>
<p>Usually, the solution is Javascript. But not really <img src='http://filipinowebdesigner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  It’s still possible to use CSS.<span id="more-34"></span></p>
<p><a href="http://filipinowebdesigner.com/samples/no-js/">This is going to be our finished product.</a> As you can see, the links are images. The text has a drop-shadow effect, something that can’t be done using CSS only without bleeding your brains out. This isn’t difficult, promise.</p>
<p><strong>STEP 1: Create the graphics</strong><br />
This is very important, though self-explanatory. Obviously, you need to create the graphics! Take note though, you need to create two graphics for each button: one for the normal state, and the other for the over state:</p>
<p><img src="http://filipinowebdesigner.com/samples/no-js/button1.gif" alt="Normal State" /><br />
The normal state</p>
<p><img src="http://filipinowebdesigner.com/samples/no-js/button1-over.gif" alt="Over state" /><br />
The over state</p>
<p><strong>STEP 2: Setup the button container</strong><br />
You need to determine first whether you want a horizontal or vertical menu. For the purpose of this tutorial, let’s make us of a horizontal one. Here’s what you need to do:</p>
<ol>
<li>Determine the width and the height of the graphic you created. In our example, the <strong>width is 200 pixels</strong> while the <strong>height is 51 pixels</strong>.</li>
<li>Take note if you want the menu to be coming from the right or from the left side. For this tutorial, we’ll pick left.</li>
<li>Setup the CSS! Pick a name for your button container. I’m corny, I’ll chose “<em>button</em>.”</li>
</ol>
<p><code><br />
.button {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width:200px;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height:51px;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin:0px;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padding:0px;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float:left;<br />
}<br />
</code></p>
<p>What this will do is to “stack” your buttons from left to right, hence creating a horizontal menu.</p>
<p><strong>STEP 3: Create the common style for links</strong><br />
As much as possible, I don’t like re-typing styles over and over again. Besides, it’s best to take advantage of the “cascading” feature of CSS—it applies styles on top of others. That’s what we’ll do. For this, we’ll create a common specification for all button links. And since we’re going to be using the .button style as a DIV tag, the following code will tell our CSS, “for all links contained inside the DIV with the .button class, apply these specifications.”</p>
<p>Here’s the code. You add this under the .button code on top on your CSS file:<br />
<code><br />
.button a {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display:block;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width:200px;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height:51px;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin:0px;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padding:0px;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text-decoration:none;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background-repeat:no-repeat;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;border-bottom:none;<br />
}<br />
</code><br />
Don’t forget to put “<code>display:block;</code>” It’s very important. Else, your button graphic won’t show.</p>
<p><strong>STEP 4: Specify the graphic backgrounds for each of the links</strong><br />
Since we’ve already specified almost all of the styles we’ll be applying for each of the links, we will only need to change the Normal state graphic, and the Over state graphic. You don’t need to repeat the other styles all over again.</p>
<p>The thing is, you have to create a different link class for each. One for Home, another for About, etc.</p>
<p>Take a look, it goes like this:<br />
<code><br />
	a.home {background-image:url(button1.gif);}<br />
	a.home:hover {background-image:url(button1-over.gif);}<br />
</code><br />
<code><br />
	a.about {background-image:url(button2.gif);}<br />
	a.about:hover {background-image:url(button2-over.gif);}<br />
</code><br />
That way, when you apply these classes on a link, it’s going to show the appropriate image background.</p>
<p><strong>STEP 5: Put everything together in HTML</strong><br />
Once you got the CSS done, it’s time for us to write the HTML markup. Here’s how it’s going to look within the “<img src="http://filipinowebdesigner.com/samples/no-js/ss-nojava2.gif" alt="body tag" />” tag.</p>
<p><img src="http://filipinowebdesigner.com/samples/no-js/ss-nojava1.gif" alt="null" /></p>
<p>As you can see, we made a space into a link. That’s actually the secret behind it all <img src='http://filipinowebdesigner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Since it’s not going to show any text, the graphic used as the background image of the link will show through.</p>
<p><a href="http://filipinowebdesigner.com/samples/no-js/">Take a look at the sample here.</a> If you’re too lazy, I’m giving you permission to just copy the source of that page <img src='http://filipinowebdesigner.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Well, hope that helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://filipinowebdesigner.com/2007/02/26/look-ma-no-javascript/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

