<?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>www.mattginsberg.net &#187; CSS Tutorials</title>
	<atom:link href="http://www.mattginsberg.net/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattginsberg.net</link>
	<description></description>
	<lastBuildDate>Wed, 12 May 2010 18:23:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tutorial: Coding the Apple&#8217;s Navigation Bar (Part 2 of 2)</title>
		<link>http://www.mattginsberg.net/tutorial-coding-the-apples-navigation-bar-part-2-of-2/</link>
		<comments>http://www.mattginsberg.net/tutorial-coding-the-apples-navigation-bar-part-2-of-2/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 04:01:47 +0000</pubDate>
		<dc:creator>Matt Ginsberg</dc:creator>
				<category><![CDATA[CSS Tutorials]]></category>
		<category><![CDATA[Photoshop Tutorials]]></category>
		<category><![CDATA[Tutorials / How To's]]></category>
		<category><![CDATA[CSS Hoverover]]></category>
		<category><![CDATA[CSS Navigation]]></category>
		<category><![CDATA[CSS Rollover]]></category>

		<guid isPermaLink="false">http://www.mattginsberg.net/?p=1959</guid>
		<description><![CDATA[In part one of this tutorial, I showed you how to create the navigation bar from Apple's website in Photoshop. In this tutorial, I will show you how to code the navigation bar in CSS. It is really easy so sit back, read over this tutorial, then open up your editing tool and get started (I used dream weaver).]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-1961 aligncenter" title="banner" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/banner8.jpg" alt="banner" width="500" height="100" /></p>
<p>In <a href="http://www.mattginsberg.net/tutorial-design-the-apples-navigation-bar-part-1-of-2/">part one</a> of this tutorial, I showed you how to create the navigation bar from Apple&#8217;s website in Photoshop. In this tutorial, I will show you how to code the navigation bar in CSS. It is really easy so sit back, read over this tutorial, then open up your editing tool and get started (I used dream weaver).</p>
<p><strong>Step One</strong></p>
<p>In part one you were left off by putting the hover part under the normal stage and saving it as one file. Here is the image for reference.<br />
<a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/appnav1.png" target="_blank"><img class="alignnone size-medium wp-image-1990" title="appnav" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/appnav1-300x21.png" alt="appnav" width="300" height="21" /></a></p>
<p>Click image to view full size. You may right click it and save it if you wish. If you followed the first tutorial, just open you image. You want to measure each link. Below is an image to clarify what I mean.</p>
<p><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/113.jpg" target="_blank"><img class="alignnone size-medium wp-image-1964" title="1" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/113-300x21.jpg" alt="1" width="300" height="21" /></a></p>
<p>Once you write those numbers down, we can begin.</p>
<h3>Step Two</h3>
<p><strong>The CSS</strong></p>
<blockquote><p><code><br />
&lt;style type="text/css"&gt;<br />
* {<br />
margin: 0px;<br />
padding:  0px;<br />
}</code></p>
<p><code>#applenav {<br />
background: url(appnav.png);<br />
height: 35px;<br />
width: 978px;<br />
margin: 0px auto;<br />
position: relative;<br />
top: 30px;<br />
}</code></p>
<p><code>#applenav li {<br />
list-style-type: none;<br />
float: left;<br />
}</code></p>
<p><code>#applenav a {<br />
height: 35px;<br />
display: block;<br />
}</code></p>
<p><code>#one { width: 110px; }<br />
#two { width: 110px; }<br />
#three { width: 106px; }<br />
#four { width: 134px; }<br />
#five { width: 103px; }<br />
#six { width: 127px; }<br />
#seven { width: 110px; }</code></p>
<p><code>#one a:hover {<br />
background: url(appnav.png) 0px -35px no-repeat;<br />
}</code></p>
<p><code>#two a:hover {<br />
background: url(appnav.png) -111px -35px no-repeat;<br />
}</code></p>
<p><code>#three a:hover {<br />
background: url(appnav.png) -220px -35px no-repeat;<br />
}</code></p>
<p><code>#four a:hover {<br />
background: url(appnav.png) -327px -35px no-repeat;<br />
}<br />
#five a:hover {<br />
background: url(appnav.png) -460px -35px no-repeat;<br />
}</code></p>
<p><code>#six a:hover {<br />
background: url(appnav.png) -563px -35px no-repeat;<br />
}</p>
<p>#seven a:hover {<br />
background: url(appnav.png) -690px -35px no-repeat;<br />
}</p>
<p>#search {<br />
width:172px;<br />
margin-left:5px;<br />
}<br />
&lt;/style&gt;</p>
<p></code></p></blockquote>
<p>Let&#8217;s explain the <strong>CSS </strong>as best we can.<br />
We have a total of eight spaces, however, only 7 will be links and the last one will be the search field. Each state is the width of each link then we have the hover state which is taking the bottom of the image (-35px &#8211; rememebr, this image is 70px high in total) and creating the hover effect. The larger numbers in the hover effect,  are the numbers that start from the left hand side of our image and go outward. This will create the hover effect because it all lines up from the top to the bottom of our image.</p>
<h3>Step Three</h3>
<p><strong>The HTML</strong></p>
<blockquote><p><code><br />
&lt;body&gt;<br />
&lt;ul id="applenav" style=" vertical-align:top"&gt;<br />
&lt;li id="one"&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="two"&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="three"&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="four"&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="five"&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="six"&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="seven"&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="search"&gt;search form here&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/body&gt;<br />
</code></p></blockquote>
<p>Let&#8217;s explain the <strong>HTML</strong> as best we can.<br />
The HTML consists of only the ul and li commands. Since this is pure CSS, all we need to do is create the simple commands to call the CSS to our image.</p>
<p><a href="http://www.mattginsberg.net/anav" target="_blank">Test it out</a></p>
<p>There you have it. Feel free to leave a comment with any question&#8217;s or trouble&#8217;s you come across.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattginsberg.net/tutorial-coding-the-apples-navigation-bar-part-2-of-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: Design the Apple&#8217;s Navigation Bar (Part 1 of 2)</title>
		<link>http://www.mattginsberg.net/tutorial-design-the-apples-navigation-bar-part-1-of-2/</link>
		<comments>http://www.mattginsberg.net/tutorial-design-the-apples-navigation-bar-part-1-of-2/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 04:01:30 +0000</pubDate>
		<dc:creator>Matt Ginsberg</dc:creator>
				<category><![CDATA[CSS Tutorials]]></category>
		<category><![CDATA[Photoshop Tutorials]]></category>
		<category><![CDATA[Tutorials / How To's]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[CSS Navigation]]></category>
		<category><![CDATA[CSS Rollover]]></category>

		<guid isPermaLink="false">http://www.mattginsberg.net/?p=1873</guid>
		<description><![CDATA[Anyone who has an iPod, iPhone, or any other Apple product more than likely has visited there website to get some sort of details on the product you will purchase. I do not have any of Apple's products, but I do visit their website often because I love the look of it. So, in this tutorial, I will help you create the Apple's navigation bar. In part one of two, I will design the actual navigation bar in Photoshop.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-1938 aligncenter" title="banner" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/banner6.jpg" alt="banner" width="500" height="100" /></p>
<p>Anyone who has an iPod, iPhone, or any other Apple product more than likely has visited there website to get some sort of details on the product you will purchase. I do not have any of Apple&#8217;s products, but I do visit their website often because I love the look of it. So, in this tutorial, I will help you create the Apple&#8217;s navigation bar. In part one of two, I will design the actual navigation bar in Photoshop.</p>
<h3>Step One</h3>
<p>Open up Photoshop, create a <span style="text-decoration: underline;">new document</span> and make it <strong>1000 pixels wide by 47 pixel high</strong>.</p>
<h3>Step Two</h3>
<p>Click the Rounded Rectange Tool, <img class="alignnone size-full wp-image-1874" title="Rounded Rectangle Tool" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/110.jpg" alt="Rounded Rectangle Tool" width="26" height="23" />, choose 4 for the radius, and make your shape. I used a red background to make it easier to see. I have this:<br />
(Click image for full view)</p>
<p><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/26.jpg" target="_blank"><img class="alignnone size-medium wp-image-1875" title="Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/26-300x14.jpg" alt="Apple Nav Bar" width="300" height="14" /></a></p>
<h3><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/26.jpg" target="_blank"></a>Step Three</h3>
<p>Add the following effects to the nav bar.</p>
<p><strong>Gradient Overlay</strong><br />
<img class="alignnone size-full wp-image-1876" title="Gradient Overlay - Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/33.jpg" alt="Gradient Overlay - Apple Nav Bar" width="592" height="438" /></p>
<p>Click image for full view.</p>
<p><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/33.jpg"></a><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/43.jpg" target="_blank"><img class="alignnone size-medium wp-image-1877" title="Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/43-300x14.jpg" alt="Apple Nav Bar" width="300" height="14" /></a></p>
<h3>Step Four</h3>
<p>Add the Apple logo and the text. Use <a href="http://gigapple.files.wordpress.com/2009/07/apple_logo.png?w=152&amp;h=186" target="_blank">this</a> for the apple logo. For the text, I used Veranda set at 11 pts and <strong>bold</strong>. Set it up to leave enough room at the right for the search field. The search field will be added in the part 2.<br />
(Click image for full view)<br />
<a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/53.jpg" target="_blank"><img class="alignnone size-medium wp-image-1879" title="Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/53-300x14.jpg" alt="5" width="300" height="14" /></a></p>
<h3>Step Five</h3>
<p>Add the following blending options to the text. This will be used for the &#8216;normal&#8217; state.</p>
<p><strong>Drop Shadow</strong><br />
<img class="alignnone size-full wp-image-1882" title="6" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/65.jpg" alt="6" width="597" height="439" /></p>
<p><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/84.jpg" target="_blank"><img class="alignnone size-medium wp-image-1884" title="8" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/84-300x14.jpg" alt="8" width="300" height="14" /></a></p>
<h3>Step Six</h3>
<p>Make a new <strong>folder </strong>and put in the three layers you have right now. Name this folder normal.<br />
<img class="alignnone size-full wp-image-1925" title="Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/93.jpg" alt="9" width="239" height="350" /></p>
<p>Close the folder, drag to to the new layer icon, and name the new folder hover.</p>
<p><img class="alignnone size-full wp-image-1926" title="Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/102.jpg" alt="10" width="238" height="377" /></p>
<p><img class="alignnone size-full wp-image-1927" title="Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/112.jpg" alt="Apple Nav Bar" width="238" height="377" /></p>
<h3>Step Seven (see edit&#8217;s at the bottom)</h3>
<p>Open up the hover folder and make change to the blending options to the third layer (the nav bar).</p>
<p><strong>Inner Shadow<br />
</strong><br />
<img class="alignnone size-full wp-image-1928" title="Apple Bar " src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/131.jpg" alt="Apple Bar " width="597" height="441" /></p>
<p><strong>Gradient Overlay</strong></p>
<p><strong><img class="alignnone size-full wp-image-1929" title="Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/141.jpg" alt="Apple Nav Bar" width="597" height="441" /></strong></p>
<p>Now change the follow of the font to black. Change the drop shadow to white.<br />
(click image for full view)</p>
<p><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/151.jpg" target="_blank"><img class="alignnone size-medium wp-image-1930" title="Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/151-300x14.jpg" alt="15" width="300" height="14" /></a></p>
<p>(This is wrong, please see updates at the bottom)</p>
<p><strong>Step Eight</strong></p>
<p>Add the lines that separate the links. Add a <strong>two new layers</strong> above the hover folder. The first layer will be a line from top to bottom in 6a6a6a. And two lines next to it (in the second layer) in white. Make the first layers opacity 42% and the second layer 9%.<br />
<a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/162.jpg"><img class="alignnone size-medium wp-image-1931" title="Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/162-300x183.jpg" alt="Apple Nav Bar" width="300" height="183" /></a></p>
<p>Then make copies of them and move them over so they are between the rest of the links.</p>
<p>Click images to view larger.</p>
<p><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/162.jpg"></a><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/172.jpg" target="_blank"><img class="alignnone size-medium wp-image-1932" title="Apple Nav Bar" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/172-300x14.jpg" alt="17" width="300" height="14" /></a></p>
<p><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/172.jpg"></a><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/182.jpg" target="_blank"><img class="alignnone size-medium wp-image-1933" title="18" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/182-300x14.jpg" alt="Apple Nav Bar" width="300" height="14" /></a></p>
<h3>Step Eight<a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/182.jpg" target="_blank"></a></h3>
<p><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/201.jpg"></a>Save the normal state and the hover state as png&#8217;s. Once you do that, you want to turn them into one image. Make the hover effect under the normal state. You new image will look like this (its ONE image):</p>
<p><a href="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/appnav.png" target="_blank"><img class="alignnone size-medium wp-image-1968" title="appnav" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/appnav-300x21.png" alt="appnav" width="300" height="21" /></a></p>
<h3>Edit to Step Seven</h3>
<p>I found that my Step Seven looks identical to Apple&#8217;s &#8216;active&#8217; link. Therefore, I am glad you saved that, however, that was for the active stage. Apply the following settings to the nav bar layer for the hover stage:</p>
<p><img class="alignnone size-full wp-image-1955" title="23" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/10/231.jpg" alt="23" width="586" height="437" /></p>
<h3></h3>
]]></content:encoded>
			<wfw:commentRss>http://www.mattginsberg.net/tutorial-design-the-apples-navigation-bar-part-1-of-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tutorial: Draggable Div with Open and Close Links.</title>
		<link>http://www.mattginsberg.net/tutorial-draggable-div-with-open-and-close-links/</link>
		<comments>http://www.mattginsberg.net/tutorial-draggable-div-with-open-and-close-links/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 04:01:53 +0000</pubDate>
		<dc:creator>Matt Ginsberg</dc:creator>
				<category><![CDATA[CSS Tutorials]]></category>
		<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[Tutorials / How To's]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[Close]]></category>
		<category><![CDATA[Drag]]></category>
		<category><![CDATA[Open]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.mattginsberg.net/?p=1697</guid>
		<description><![CDATA[If you read my first draggable div tutorial, you would know that I had planned to show you how to add a close and open function for this. So within this tutorial, I plan to show you what the old code looked like, and how to add the two extra functions. At the bottom of the tutorial you will see a link to view it in action.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-1698 aligncenter" title="banner2" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/09/banner22.jpg" alt="banner2" width="500" height="100" /></p>
<p style="text-align: left;">If you read my first <a href="http://www.mattginsberg.net/tutorial-draggable-div/">draggable div tutorial</a>, you would know that I had planned to show you how to add a close and open function for this. So within this tutorial, I plan to show you what the old code looked like, and how to add the two extra functions. At the bottom of the tutorial you will see a link to view it in action.</p>
<p style="text-align: left;">
<p style="text-align: left;"><span style="text-decoration: underline;"><strong>Here is the full code from the previous tutorial:<br />
</strong></span><a href="http://www.mattginsberg.net/dragdiv" target="_blank">See it in action.</a><span style="text-decoration: underline;"><strong> </strong></span></p>
<blockquote><p><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br />
&lt;title&gt;Untitled Document&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;style type="text/css"&gt;<br />
#maindiv{<br />
z-index:10;<br />
background: #FFC;<br />
color:#000;<br />
width: 400px;<br />
height: 250px;<br />
position: absolute;<br />
top: 50px;<br />
left: 50px;<br />
padding:10px;<br />
}<br />
#header{<br />
color:#000000;<br />
background: #CCC;<br />
padding:5px;<br />
text-align:center;<br />
}<br />
#header:hover{<br />
color:#fff;<br />
background:#000;<br />
text-align:center;<br />
}<br />
&lt;/style&gt;<br />
&lt;script language="javascript"&gt;<br />
var drag=0;<br />
var xdif=0;<br />
var ydif=0;<br />
var initx="50px";<br />
var inity="50px";<br />
function begindrag(event){<br />
if(drag==0){<br />
floatingd = document.getElementById("maindiv");<br />
if(floatingd.style.left==""){<br />
floatingd.style.left=initx;<br />
}<br />
if(floatingd.style.top==""){<br />
floatingd.style.top=inity;<br />
}<br />
prex=floatingd.style.left.replace(/px/,"");<br />
prey=floatingd.style.top.replace(/px/,"");<br />
drag=1;<br />
xdif=event.clientX-prex;<br />
ydif=event.clientY-prey;<br />
}else{<br />
drag=0;<br />
}<br />
}<br />
function mousepos(event){<br />
floatingd = document.getElementById("maindiv");<br />
if(drag==1){<br />
floatingd.style.left = event.clientX-xdif+"px";<br />
floatingd.style.top = event.clientY-ydif+"px";;<br />
}<br />
}<br />
&lt;/script&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY onMouseMove="mousepos(event)" &gt;<br />
&lt;div id='maindiv'&gt;<br />
&lt;div id='header' onclick="begindrag(event)" style="cursor:move"&gt;click in this region then move your mouse around&lt;/div&gt;<br />
&lt;br /&gt;<br />
Once you move it, then click on the mouse again to release it.... very easy and cool. <img src='http://www.mattginsberg.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  This is perfect for advertising, or a website with stats. &lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p></blockquote>
<p>Now, it is very simple to add the open and close functions to this. <span style="text-decoration: underline;"><strong><em><br />
You want to add this into the Javascript code</em></strong></span>:</p>
<blockquote><p><code> function closeit(){document.getElementById("maindiv").style.display="none"}<br />
function loadwindow(){document.getElementById("maindiv").style.display="block"}<br />
</code></p></blockquote>
<p><strong>Your <span style="text-decoration: underline;">full Javascript code</span> should look like this:</strong></p>
<blockquote><p><code>&lt;script language="javascript"&gt;<br />
var drag=0;<br />
var xdif=0;<br />
var ydif=0;<br />
var initx="50px";<br />
var inity="50px";<br />
function begindrag(event){<br />
if(drag==0){<br />
floatingd = document.getElementById("maindiv");<br />
if(floatingd.style.left==""){<br />
floatingd.style.left=initx;<br />
}<br />
if(floatingd.style.top==""){<br />
floatingd.style.top=inity;<br />
}<br />
prex=floatingd.style.left.replace(/px/,"");<br />
prey=floatingd.style.top.replace(/px/,"");<br />
drag=1;<br />
xdif=event.clientX-prex;<br />
ydif=event.clientY-prey;<br />
}else{<br />
drag=0;<br />
}<br />
}<br />
function mousepos(event){<br />
floatingd = document.getElementById("maindiv");<br />
if(drag==1){<br />
floatingd.style.left = event.clientX-xdif+"px";<br />
floatingd.style.top = event.clientY-ydif+"px";;<br />
}<br />
}<br />
function closeit(){<br />
document.getElementById("maindiv").style.display="none"<br />
}<br />
function loadwindow(){<br />
document.getElementById("maindiv").style.display="block"<br />
}<br />
&lt;/script&gt;</code></p></blockquote>
<p><strong>You now want to add the close div link into your HTML. To close the div, use the following HTML code:</strong><br />
<em><span style="text-decoration: underline;">Make sure to enter this code inside of the maindiv.</span></em></p>
<blockquote><p><code> &lt;p onClick="closeit()" style="cursor:pointer"&gt;close this div&lt;/p&gt;<br />
</code></p></blockquote>
<p><strong>You now want to add the open div link into your HTML. To open the div, use the following HTML code:</strong><br />
<em><span style="text-decoration: underline;">Make sure this code is not inside of the maindiv. </span></em></p>
<blockquote><p><code> &lt;div onclick="loadwindow()" style="cursor:pointer"&gt;Load Div&lt;/div&gt;<br />
</code></p></blockquote>
<p><strong>Here is the full code with the open and close links:</strong></p>
<blockquote><p><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br />
&lt;title&gt;Draggable Div&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;style type="text/css"&gt;<br />
#maindiv{<br />
z-index:10;<br />
background: #FFC;<br />
color:#000;<br />
width: 400px;<br />
height: 250px;<br />
position: absolute;<br />
top: 50px;<br />
left: 50px;<br />
padding:10px;<br />
}<br />
#header{<br />
color:#000000;<br />
background: #CCC;<br />
padding:5px;|<br />
text-align:center;<br />
}<br />
#header:hover{<br />
color:#fff;<br />
background:#000;<br />
text-align:center;<br />
}<br />
&lt;/style&gt;<br />
&lt;script language="javascript"&gt;<br />
var drag=0;<br />
var xdif=0;<br />
var ydif=0;<br />
var initx="50px";<br />
var inity="50px";<br />
function begindrag(event){<br />
if(drag==0){<br />
floatingd = document.getElementById("maindiv");<br />
if(floatingd.style.left==""){<br />
floatingd.style.left=initx;<br />
}<br />
if(floatingd.style.top==""){<br />
floatingd.style.top=inity;<br />
}<br />
prex=floatingd.style.left.replace(/px/,"");<br />
prey=floatingd.style.top.replace(/px/,"");<br />
drag=1;<br />
xdif=event.clientX-prex;<br />
ydif=event.clientY-prey;<br />
}else{<br />
drag=0;<br />
}<br />
}<br />
function mousepos(event){<br />
floatingd = document.getElementById("maindiv");<br />
if(drag==1){<br />
floatingd.style.left = event.clientX-xdif+"px";<br />
floatingd.style.top = event.clientY-ydif+"px";;<br />
}<br />
}<br />
function closeit(){<br />
document.getElementById("maindiv").style.display="none"<br />
}<br />
function loadwindow(){<br />
document.getElementById("maindiv").style.display="block"<br />
}<br />
&lt;/script&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY onMouseMove="mousepos(event)" &gt;<br />
&lt;div id='maindiv'&gt;<br />
&lt;div id='header' ononclick="begindrag(event)" style="cursor:move"&gt;click in this region then move your mouse around&lt;/div&gt;<br />
&lt;p&gt;&lt;br /&gt;<br />
Once you move it, then click on the mouse again to release it.... very easy and cool. <img src='http://www.mattginsberg.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  This is perfect for advertising, or a website with stats. &lt;/p&gt;<br />
&lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
&lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
&lt;p onClick="closeit()" style="cursor:pointer"&gt;close this div&lt;/p&gt;<br />
&lt;/div&gt;<br />
&lt;div onclick="loadwindow()" style="cursor:pointer"&gt;Load Div&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p></blockquote>
<p><a href="http://www.mattginsberg.net/ocdragdiv" target="_blank">See it in action.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattginsberg.net/tutorial-draggable-div-with-open-and-close-links/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tutorial: Draggable Div</title>
		<link>http://www.mattginsberg.net/tutorial-draggable-div/</link>
		<comments>http://www.mattginsberg.net/tutorial-draggable-div/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 04:01:06 +0000</pubDate>
		<dc:creator>Matt Ginsberg</dc:creator>
				<category><![CDATA[CSS Tutorials]]></category>
		<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[Tutorials / How To's]]></category>
		<category><![CDATA[Div]]></category>
		<category><![CDATA[Grad]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.mattginsberg.net/?p=1665</guid>
		<description><![CDATA[Creating a div is, as you already (should) know, is very easy. A div is a great way to layout a website for many reasons. In this tutorial, I will show you how to create a div that lays on top of your content, and then the user can move it around the screen as they see fit.Also, you can see how to add a link within your website that will open the div and a link to close it. ]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone size-full wp-image-1685" title="banner" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/09/banner4.jpg" alt="banner" width="500" height="100" /></p>
<p style="text-align: left;">Creating a div is, as you already (should) know, is very easy. A div is a great way to layout a website for many reasons. In this tutorial, I will show you how to create a div that lays on top of your content, and then the user can move it around the screen as they see fit. Also, you can see how to add a link within your website that will open the div and a link to close it. If you want to learn more, <a href="http://www.mattginsberg.net/tutorial-draggable-div-with-open-and-close-links">read this tutorial</a>.</p>
<p style="text-align: left;">The first thing you want to do is create a new HTML file, or use a file that you are working with right now. You want to add the following CSS to the stylesheet. If you do have the stylesheet, be sure not to include the &lt;style type=&#8221;text/css&#8221;&gt; and the &lt;/style&gt;. If you do not have an external stylesheet, add the below after the head section and before the body section.</p>
<p style="text-align: left;">
<blockquote><p><code><br />
&lt;style type="text/css"&gt;<br />
#maindiv{<br />
z-index:10;<br />
background: #FFC;<br />
color:#000;<br />
width: 400px;<br />
height: 250px;<br />
position: absolute;<br />
top: 50px;<br />
left: 50px;<br />
padding:10px;<br />
}<br />
#header{<br />
color:#000000;<br />
background: #CCC;<br />
padding:5px;<br />
text-align:center;<br />
}<br />
#header:hover{<br />
color:#fff;<br />
background:#000;<br />
text-align:center;<br />
}<br />
&lt;/style&gt;</code></p></blockquote>
<p><strong>Next you want to add the Javascript. Below is the code.</strong></p>
<blockquote><p><code><br />
&lt;script language="javascript"&gt;<br />
var drag=0;<br />
var xdif=0;<br />
var ydif=0;<br />
var initx="50px";<br />
var inity="50px";<br />
function begindrag(event){<br />
if(drag==0){<br />
floatingd = document.getElementById("maindiv");<br />
if(floatingd.style.left==""){<br />
floatingd.style.left=initx;<br />
}<br />
if(floatingd.style.top==""){<br />
floatingd.style.top=inity;<br />
}<br />
prex=floatingd.style.left.replace(/px/,"");<br />
prey=floatingd.style.top.replace(/px/,"");<br />
drag=1;<br />
xdif=event.clientX-prex;<br />
ydif=event.clientY-prey;<br />
}else{<br />
drag=0;<br />
}<br />
}<br />
function mousepos(event){<br />
floatingd = document.getElementById("maindiv");<br />
if(drag==1){<br />
floatingd.style.left = event.clientX-xdif+"px";<br />
floatingd.style.top = event.clientY-ydif+"px";;<br />
}<br />
}<br />
&lt;/script&gt;<br />
</code></p></blockquote>
<p><strong>Now you want to put the following code in the &lt;body&gt; script like so:</strong></p>
<blockquote><p><code><br />
&lt;<strong>body onMouseMove="mousepos(event)"</strong> &gt;<br />
</code></p></blockquote>
<p><strong>And <span style="text-decoration: underline;">finally</span>, enter the following HTML code into the body section of your website.</strong></p>
<blockquote><p><code><br />
&lt;div id='maindiv'&gt;<br />
&lt;div id='header' onclick="begindrag(event)" style="cursor:move"&gt;click in this region then move your mouse around&lt;/div&gt;<br />
&lt;br /&gt;<br />
Once you move it, then click on the mouse again to release it.... very easy and cool. This is perfect for advertising, or a website with stats. &lt;/div&gt;</code></p></blockquote>
<p><span style="text-decoration: underline;"><strong>Here is the full code:</strong></span></p>
<blockquote><p><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br />
&lt;title&gt;Untitled Document&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;style type="text/css"&gt;<br />
#maindiv{<br />
z-index:10;<br />
background: #FFC;<br />
color:#000;<br />
width: 400px;<br />
height: 250px;<br />
position: absolute;<br />
top: 50px;<br />
left: 50px;<br />
padding:10px;<br />
}<br />
#header{<br />
color:#000000;<br />
background: #CCC;<br />
padding:5px;<br />
text-align:center;<br />
}<br />
#header:hover{<br />
color:#fff;<br />
background:#000;<br />
text-align:center;<br />
}<br />
&lt;/style&gt;<br />
&lt;script language="javascript"&gt;<br />
var drag=0;<br />
var xdif=0;<br />
var ydif=0;<br />
var initx="50px";<br />
var inity="50px";<br />
function begindrag(event){<br />
if(drag==0){<br />
floatingd = document.getElementById("maindiv");<br />
if(floatingd.style.left==""){<br />
floatingd.style.left=initx;<br />
}<br />
if(floatingd.style.top==""){<br />
floatingd.style.top=inity;<br />
}<br />
prex=floatingd.style.left.replace(/px/,"");<br />
prey=floatingd.style.top.replace(/px/,"");<br />
drag=1;<br />
xdif=event.clientX-prex;<br />
ydif=event.clientY-prey;<br />
}else{<br />
drag=0;<br />
}<br />
}<br />
function mousepos(event){<br />
floatingd = document.getElementById("maindiv");<br />
if(drag==1){<br />
floatingd.style.left = event.clientX-xdif+"px";<br />
floatingd.style.top = event.clientY-ydif+"px";;<br />
}<br />
}<br />
&lt;/script&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY onMouseMove="mousepos(event)" &gt;<br />
&lt;div id='maindiv'&gt;<br />
&lt;div id='header' onclick="begindrag(event)" style="cursor:move"&gt;click in this region then move your mouse around&lt;/div&gt;<br />
&lt;br /&gt;<br />
Once you move it, then click on the mouse again to release it.... very easy and cool. <img src='http://www.mattginsberg.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  This is perfect for advertising, or a website with stats. &lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p></blockquote>
<p><a href="http://www.mattginsberg.net/dragdiv" target="_blank">See it in action.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattginsberg.net/tutorial-draggable-div/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tutorial: Image Rollover in CSS</title>
		<link>http://www.mattginsberg.net/tutorials-image-rollover-in-css/</link>
		<comments>http://www.mattginsberg.net/tutorials-image-rollover-in-css/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 04:01:07 +0000</pubDate>
		<dc:creator>Matt Ginsberg</dc:creator>
				<category><![CDATA[CSS Tutorials]]></category>
		<category><![CDATA[Tutorials / How To's]]></category>
		<category><![CDATA[CSS Rollover]]></category>
		<category><![CDATA[Rollover Effect]]></category>

		<guid isPermaLink="false">http://www.mattginsberg.net/?p=1495</guid>
		<description><![CDATA[When designing a website, you may want to use your own custom made buttons. However, in the older days, you would write a lot of HTML code just to get the rollover to work. Sometimes, it wasn't even worth the trouble. But with the new days of CSS - life is much easier. This tutorial will describe, and show you how to do a rollover effect with using CSS. This would be perfect if you have an image gallery in your website, menu buttons, or whatever you decide to use it on. Most of you know what this would be like when doing normal text, but with an image, you can do just about anything. ]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><span><span><img class="size-full wp-image-1499 aligncenter" title="banner" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/07/banner1.jpg" alt="banner" width="500" height="100" /></span></span></p>
<p><span><span>When designing a website, you may want to use your own custom made buttons. However, in the older days, you would write a lot of HTML code just to get the rollover to work. Sometimes, it wasn&#8217;t even worth the trouble. But with the new days of CSS &#8211; life is much easier. This tutorial will describe, and show you how to do a rollover effect with using CSS. This would be perfect if you have an image gallery in your website, menu buttons, or whatever you decide to use it on. Most of you know what this would be like when doing normal text, but with an image, you can do just about anything. </span></span></p>
<p>First, you need to <strong>create a graphic</strong> that you want to use. You may use mine if you wish.</p>
<p><img class="alignnone size-full wp-image-1497" title="1" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/07/113.jpg" alt="1" width="80" height="50" /></p>
<p>This graphic contains the original state, and the roll over state in one image. The total size of this image is 80 x 50 Pixels.</p>
<p><strong>Why is this better than two images?</strong><br />
If you use two images, then the website needs to load both images. Whereas in this example, when the website loads, it loads the entire image, but only shows the original state, not the roll over stats.</p>
<p><span>Here is the CSS &#8211; put this in your stylesheet.</span></p>
<blockquote><p><code>&lt;style&gt;<br />
#button a {display: block; background:  url(http://www.mattginsberg.net/blog/wp-content/uploads/2009/07/113.jpg) top; width: 80px; height: 25px; }<br />
#button a:hover {background:  url(http://www.mattginsberg.net/blog/wp-content/uploads/2009/07/113.jpg) no-repeat bottom;}<br />
&lt;/style&gt;<br />
</code></p></blockquote>
<p><strong>Let&#8217;s look at the CSS:</strong></p>
<p><span><span><strong> + #button a</strong> &#8211; our button will be a link, therefore we use a<br />
<strong> + display: block</strong> &#8211; makes it possible to click on the whole block of the element<br />
<strong> + background: url(http://www.mattginsberg.net/blog/wp-content/uploads/2009/07/113.jpg) top</strong> &#8211; our rollover graphic<br />
<strong> + width:</strong> &#8211; width of our object<br />
<strong> + height:</strong> &#8211; height of our object, but only for one state, that’s why it’s 25 pixels.</span></span></p>
<p><span><span>Put the following code in your document to place the roll over button:</span></span></p>
<blockquote><p><code>&lt;div id="button"&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/div&gt;</code></p></blockquote>
<p><span><strong> Test it:</strong></span></p>
<style> #button a {display: block; background:  url(http://www.mattginsberg.net/blog/wp-content/uploads/2009/07/113.jpg) top; width: 80px; height: 25px; }#button a:hover {background:  url(http://www.mattginsberg.net/blog/wp-content/uploads/2009/07/113.jpg) no-repeat bottom;} </style>
<div id="button"><a href="#"></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.mattginsberg.net/tutorials-image-rollover-in-css/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
