<?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>Design Shack &#187; interface</title>
	<atom:link href="http://designshack.net/tag/interface/feed" rel="self" type="application/rss+xml" />
	<link>http://designshack.net</link>
	<description>Inspiration, CSS Gallery &#38; Community News</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:00:00 +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>Developing a jQuery Private Messaging Modal Box</title>
		<link>http://designshack.net/articles/javascript/developing-a-jquery-private-messaging-modal-box/</link>
		<comments>http://designshack.net/articles/javascript/developing-a-jquery-private-messaging-modal-box/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 14:39:33 +0000</pubDate>
		<dc:creator>Jake Rocheleau</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[popover]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=23908</guid>
		<description><![CDATA[You can build some really neat things using jQuery. The latest release bundle updates a lot of bugs and even hints at support for a new jQuery Mobile. With frontend scripting you can build practically any type of web application. But more specifically we&#8217;ll be looking into constructing a small modal box window. I have [...]]]></description>
			<content:encoded><![CDATA[<p>You can build some really neat things using jQuery. The latest release bundle updates a lot of bugs and even hints at support for a new <a href="http://designshack.net/community/how-to-write-a-simple-application-on-jquery-mobile">jQuery Mobile</a>. With frontend scripting you can build practically any type of web application. But more specifically we&#8217;ll be looking into constructing a small modal box window.</p>
<p>I have designed the functionality to look and feel like a private messaging solution. This is perfect to implement on a user profile page or author&#8217;s page in a blog. We will be using some handy CSS3 techniques along with coding the page structure in HTML5. You don&#8217;t need to be a master jQuery artist to understand this tutorial, but it wouldn&#8217;t hurt to brush up on the basics. Check out my live demo example and download the project source code below.</p>
<p><span id="more-23908"></span><br />
<em>Like the article? Be sure to subscribe to our <a href="feed://feeds.feedburner.com/designshack">RSS feed</a> and follow us on <a href="http://twitter.com/designshack">Twitter</a> to stay up on recent content.</em></p>
<h2>Try It Out</h2>
<p style="text-align:center"><strong><a href="http://designshack.net/tutorialexamples/jQueryModal/index.html">View Live Demo</a></strong> &#8211; <strong><a href="http://designshack.net/tutorialexamples/jQueryModal/jquery-modal-form.zip">Download Source</a></strong></p>
<div class="tutorialimage"><a href="http://designshack.net/tutorialexamples/jQueryModal/index.html" target="_blank"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/jquery-modal-example-screenshot.jpg" alt="jQuery Modal Box Screen" width="510" /></a></div>
<h2>The HTML Structure</h2>
<p>Before we dive into jQuery let&#8217;s examine a bit of the HTML first. If you&#8217;re interested in examining the whole document layout I suggest downloading from the source code. But I&#8217;d like to focus on the modal box HTML code for further explanation.</p>
<p>I split the template using HTML5 <code>&lt;section&gt;</code> tags. Inside I have a div with the class <code>.containmsg</code> which holds our modal box and button to show/hide the contents. The modal container uses the class <code>.mainCompose</code>. This is also how we target in jQuery &#8211; let&#8217;s look at the HTML code for this below.</p>
<div style="overflow: auto;background-color: #eeeeee">

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- begin modal msg box --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;containmsg&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;img/compose.gif&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;compose&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;compose&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mainComposeD&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;calloutUp&quot;</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;calloutUp2&quot;</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>	
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sendprivatemsg&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tofield&quot;</span>&gt;</span>To<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;userslist clearfix&quot;</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.net/author/jakerocheleau/&quot;</span> <span style="color: #000066;">target</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;_blank&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;recipient&quot;</span>&gt;</span>Jake Rocheleau<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
&nbsp;
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;break&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mymsg&quot;</span>&gt;</span>Message<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">textarea</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mymsg&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">textarea</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>**Enter some text!<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sendbtn&quot;</span>&gt;</span>Send Message<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;img/ajax-loader.gif&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;loader&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- @end modal --&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>Inside our form element there aren&#8217;t any surprises. A small label and input message field. Also a to: field with a link to the user&#8217;s page. In this demo I linked to my DesignShack author page. It&#8217;s not required, though. You could even remove the link altogether and still keep the CSS styles in-tact. The users list is coded as a UL element so you could support messaging to more than one person.</p>
<p>Now before we dive into jQuery there&#8217;s one more technique I wanted to cover. If you click the compose icon you&#8217;ll notice our modal box has a small triangle tip at the very top. You could use images for this technique, but there is a simpler alternative using strictly CSS.</p>
<h2>Cool CSS Tooltip Triangles</h2>
<p>There is a small div which appears directly above the message form. This contains two classes labeled <strong>calloutUp</strong> and <strong>calloutUp2</strong>. The former behaves as a continuation of our outer border (the darker tan) while the latter connects to the center of our form area. Using both we can create matching triangles in a tooltip style connector.</p>
<p>This works because of a setting in CSS that makes all borders come together in center as a triangle. So we can set both of these divs to have no height or width, but massive borders. If we only give color to one of the borders and the rest are transparent we create the triangle effect seen here. Check out the CSS classes for both of the callouts.</p>
<div style="overflow: auto;background-color: #eeeeee">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.calloutUp</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#f0ecd0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span> <span style="color: #993333;">dotted</span> <span style="color: #993333;">transparent</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span> <span style="color: #993333;">dotted</span> <span style="color: #993333;">transparent</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">30px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">10</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.calloutUp2</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-12px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#faf7e3</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span> <span style="color: #993333;">dotted</span> <span style="color: #993333;">transparent</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">transparent</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">11</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>I&#8217;m also setting details for the surrounding borders because this keeps the div block looking square. Otherwise our shape would turn rectangular, and then our triangles would come out lopsided with jagged edges. The <code>z-index</code> property is also important so that our inner tip will stay above the outer tip. The other styles are used to mockup our fonts in the demo example, certainly nothing extraordinary.</p>
<h2>Developing Interactions with jQuery</h2>
<p>Now we can delve into the good stuff! If you have used jQuery before you&#8217;ll likely be familiar with starting off a new document. First include the latest version of jQuery into your page. If you don&#8217;t wish to download and host the file yourself Google offers all versions of jQuery live for developers. The latest I&#8217;m using is <a href="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">library 1.6.2 mini</a>.</p>
<p>Once that&#8217;s included you should open another script tag for JavaScripting. I decided to write my code within the head block of the same HTML page. But you could alternatively move this to the body, footer, or even into an external file. The first snippets of code I&#8217;ve added below.</p>
<div style="overflow: auto;background-color: #eeeeee">

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.mainCompose&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.loader'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#errortxt'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.compose'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.mainCompose'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideToggle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<p></ br></p>
<p>We call our <code>$(document).ready()</code> function to hold off on any actions until the page is finished loading. The first task is to hide 3 page elements right away. These are <code>.mainCompose</code> to hide our modal box, <code>.loader</code> to hide the ajax loading gif, and <code>#errortxt</code> which only displays if the user hasn&#8217;t entered anything and tries to submit the form. Each of these elements will only be displayed under certain conditions so it&#8217;s best to keep them hidden immediately.</p>
<p>And finally our first scripting action is checking for a click event handler. The <code>.compose</code> class is actually tied to our compose image even though there is no anchor link to be clicked. jQuery can handle the click events and call <a href="http://api.jquery.com/slideToggle/">slideToggle()</a> either way. Now the last bit of code to examine is how we can pull data out from user input.</p>
<h2>Processing the Modal Form</h2>
<p>We are only checking for one more final event handler. This is tied to the click event of our <code>.sendbtn</code>, which is actually tied to an anchor link in our modal box. Directly next to this is our animated ajax .gif image which was hidden right after the page loaded.</p>
<div style="overflow: auto;background-color: #eeeeee">

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.sendbtn'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.sendbtn'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.loader'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mymsg'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#errortxt'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.sendbtn'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.loader'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sendbtn'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.loader'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#errortxt'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> formQueryString <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#sendprivatemsg'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// form data for ajax input</span>
		finalSend<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    		
	<span style="color: #009900;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>The execution function right after our button is click now has a parameter. <code>function(e)</code> just passes the instance of our click event right into the function as a variable. We use this event selector to call the <a href="http://api.jquery.com/event.preventDefault/">preventDefault()</a> method so that our link doesn&#8217;t behave as a link. We also immediately hide the .sendbtn and replace it with our .loader image.</p>
<p>Next we pass into a standard if/else clause checking the <code>#mymsg</code> textarea value. If this contains no text then we know the user hasn&#8217;t entered anything. In this case we display our error message and re-hide the loading image while displaying our button again. Otherwise we enter the <code>else{ }</code> clause which assumes we can send the message!</p>
<p>I haven&#8217;t written any Ajax/PHP code since it jumps out of range of this tutorial. But you should check out the <a href="http://api.jquery.com/jQuery.ajax/">jQuery ajax() function</a> which can speed up backend development tenfold. I have set aside a variable <code>formQueryString</code> which can be used to pass the form data into an Ajax call. Instead I&#8217;ll be just finishing up the aesthetics in a small function <strong>finalSend();</strong></p>
<div style="overflow: auto;background-color: #eeeeee">

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	<span style="color: #006600; font-style: italic;">// possibly include Ajax calls here to external PHP</span>
	<span style="color: #003366; font-weight: bold;">function</span> finalSend<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.mainCompose'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">delay</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideToggle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#composeicon'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sent'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'compose'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// hide original link and display confirmation icon</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#composebtn'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;lt;img src=&quot;img/check-sent.png&quot; /&amp;gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<p></ br></p>
<p>What we want to do now is close our modal box and display a small check icon to let the user know everything is fine and dandy. I&#8217;ve used <a href="http://api.jquery.com/delay/">.delay()</a> to keep the modal box open for 1 second before calling our final slideToggle() method. This was added solely for appearances in this tutorial so you can see how it looks waiting for the server to load. If you want to keep your users waiting an extra second you could leave this &#8211; but it serves little point otherwise!</p>
<p>After the slide animation I&#8217;ve added a callback function. It only includes 2 lines of basic code. First we target the compose icon and change its class from <code>.compose</code> to <code>.sent</code>, then hide it from view. Finally we target <code>#composebtn</code> which is the container div of our icon and append a new check mark icon. Now our users know the message was sent and we&#8217;ve barely used any screen real estate!</p>
<p style="text-align:center"><strong><a href="http://designshack.net/tutorialexamples/jQueryModal/index.html">View Live Demo</a></strong> &#8211; <strong><a href="http://designshack.net/tutorialexamples/jQueryModal/jquery-modal-form.zip">Download Source</a></strong></p>
<h2>Conclusion</h2>
<p>This tutorial should have gotten you a bit more comfortable building a scalable modal box in jQuery. We have built some great CSS styles and used some basic form processing to enhance the user interaction. There is certainly a lot you could add on but our example lays the ground structure and paves the road for higher possibilities.</p>
<p>If you&#8217;re still looking to check out my demo or download the source code you can do so below. Reading code can be confusing after long periods of time, so I recommend downloading the source directly to get a better idea of how this small app functions. Similarly if you have any questions or ideas you can offer them in the discussion area.</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/javascript/developing-a-jquery-private-messaging-modal-box/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>10 Fresh Mac Apps With Beautiful Interfaces (and What We Can Learn From Them)</title>
		<link>http://designshack.net/articles/software/10-fresh-mac-apps-with-beautiful-interfaces-and-what-we-can-learn-from-them/</link>
		<comments>http://designshack.net/articles/software/10-fresh-mac-apps-with-beautiful-interfaces-and-what-we-can-learn-from-them/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 18:17:49 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=14868</guid>
		<description><![CDATA[Interface design is a valuable skill to possess. Every decision you make, be it something as major as a color scheme or as minor as a stroke width, can potentially have a huge impact on whether or not people decide to use the application, website, etc. We designers know this better than anyone because we [...]]]></description>
			<content:encoded><![CDATA[<p>Interface design is a valuable skill to possess. Every decision you make, be it something as major as a color scheme or as minor as a stroke width, can potentially have a huge impact on whether or not people decide to use the application, website, etc. We designers know this better than anyone because we tend to be interface snobs, meaning we flat out refuse to use an app with poor design, even if the functionality is stellar. </p>
<p>The next time you&#8217;re faced with the task of designing an interface, why not learn from those who have already succeeded? Below we&#8217;ll take a look at the interfaces of ten beautiful and fairly new Mac applications and discuss what went right. </p>
<p><span id="more-14868"></span><br />
<em>Like the article? Be sure to subscribe to our <a href="feed://feeds.feedburner.com/designshack">RSS feed</a> and follow us on <a href="http://twitter.com/designshack">Twitter</a> to stay up on recent content.</em></p>
<h2><a href="http://www.6wunderkinder.com/wunderlist/">Wunderlist</a></h2>
<p>The wizards at 6Wunderkinder are quietly taking over the productivity app industry with a killer combination: great design, simple functionality and an unbeatable price tag (free). Both their iPhone and desktop app look just excellent. </p>
<div class="tutorialimage"><a href="http://www.6wunderkinder.com/wunderlist/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-3.jpg" alt="screenshot" width="510"/></a></div>
<p>The key to the awesomeness of the Wunderlist interface is something extremely simple that we just don&#8217;t see enough of in Mac application interfaces: customization. Wunderlist comes built in with a whole bunch of gorgeous backgrounds like the wooden one shown above. Since the UI elements are actually fairly minimal, swapping out the background changes the entire personality of the application! </p>
<p>Why spend hours scratching your head wondering what your users will like the most when you know that every user is different? Providing your users with a number of equally attractive but very different options is a solid way to increase customer satisfaction. One important hint: make sure it&#8217;s easy to switch between the options. As a rule of thumb, if you have to write a tutorial on how to do it, it&#8217;s too complex. Wunderlist simply provides a row of icons at the bottom of the window. When you click on one, the background changes. It&#8217;s that simple. </p>
<p>The one killer feature that I think would make this even better is if users could use their own images as a background. Sure, plenty of your users will choose something hideous but there will also be a ton of users who come up with something that&#8217;s actually better than the built-in options.</p>
<p>I&#8217;m making a prediction that lots of developers will follow in the footsteps of 6Wunderkinder and begin offering users the ability to personalize their application interfaces to fit their unique personalities. </p>
<h2><a href="http://reederapp.com/">Reeder</a></h2>
<p>Reeder for Mac is making a big splash in the Mac design community. Most of us have used NetNewsWire for ages and are definitely sick of the stagnant and boring interface. By contrast, Reeder is a breath of fresh air offering a  notably clean and non-cluttered looking interface for an RSS reader. </p>
<div class="tutorialimage"><a href="http://reederapp.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-1.jpg" alt="screenshot" width="510"/></a></div>
<p>The awesome thing about Reeder is that it represents another growing trend you can expect to see on the rise in the next few years: Apple iOS design on the desktop (Reeder began life on iOS). The iPhone lit a wildfire under interface developers who began churning out buttery smooth interfaces unlike anything we&#8217;d ever seen. This fire has recently been lit anew with the arrival of the iPad and innovative new interactive experiences like Flipboard. </p>
<p>Gradually, we&#8217;ve been seeing these design trends trickle back to the Mac. Even Apple has realized the benefits of iOS-like interfaces and is incorporating many of these benefits into OS X Lion, the next major release of Apple&#8217;s legendary desktop operating system. </p>
<h2><a href="http://sparrowmailapp.com/">Sparrow</a></h2>
<p>I hesitated to add Sparrow because it is quite controversial among designers. The reason for this is that it represents a shameless ripoff of the UI of another popular application: <a href="http://www.atebits.com/tweetie-mac/">Tweetie for Mac</a>. </p>
<div class="tutorialimage"><a href="http://sparrowmailapp.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-2.jpg" alt="screenshot" width="510"/></a></div>
<p>On one side of this debate you have legitimate claims that Tweetie has been stagnant in development for quite a while now and will likely stay that way because of its acquisition by Twitter (who really just wanted the iPhone app). Designers on the other side claim that it&#8217;s pretty uncool to rip off another man&#8217;s interface no matter the circumstances.</p>
<p>Regardless of which side of the debate you&#8217;re on, Sparrow is an interesting example for one important reason. It took a format that we were used to in one category (Twitter apps) and sought to apply it in a completely different context (email). This type of thinking is a stellar source of innovation. Take a look at all the apps you use every day, now take a look at the competing apps in that category. Chances are, they&#8217;re all about the same because someone innovated the category and everyone else simply followed. If you want to create something truly different, ask yourself how you could take the concept of that app and fit it into the structure of an app from a different category. You might just revolutionize an entire category.  </p>
<h2><a href="http://kiwi-app.net/">Kiwi 2</a></h2>
<p>Though the functionality still doesn&#8217;t feel quite as smooth as Tweetie, Kiwi has to be one of the most attractive desktop Twitter clients on the market.</p>
<div class="tutorialimage"><a href="http://kiwi-app.net/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-4.jpg" alt="screenshot" width="510"/></a></div>
<p>As with Wunderlist, the key element here is customization. Kiwi offers users a number of themes to choose from that radically alter the appearance of the application. Wunderlist takes the simple route and offers different backgrounds, but in Kiwi, everything in your stream changes. This includes the shape and color of the tweets, the background and the appearance of the icons. Even the functionality alters pretty dramatically from one theme to the next. For instance, one theme simply shows you a list of usernames and hides the actual tweets until you click on a user to see what they said. </p>
<p>The execution here is very important. Kiwi doesn&#8217;t require you to choose a specific theme or walk you through some advanced setup process. The app has all the default settings worked out for you. In fact, if you never poke around in the preferences menu, you could use Kiwi for quite a while before even finding the customization options. They&#8217;re not exactly hidden, power users will find them in the first place they think to look. However, users who want a simple experience aren&#8217;t being hit over the head with intimidating decisions that they&#8217;re not prepared to make. </p>
<p>The lesson here is that customization should be both simple and optional. Don&#8217;t force your users into it or they&#8217;ll close the app and turn elsewhere. Let your users love your app for what it is and work their way up to making it look how they want as they become more familiar with how everything works. </p>
<h2><a href="http://www.daisydiskapp.com/">DaisyDisk</a></h2>
<p>Daisy Disk is the most attractive hard drive storage visualization I&#8217;ve ever seen. The retro futuristic charts look so good you&#8217;ll want to print them and use them as office art. </p>
<div class="tutorialimage"><a href="http://www.daisydiskapp.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-5.jpg" alt="screenshot" width="510"/></a></div>
<p>The important question to ask here is whether or not you have to sacrifice usability in your quest for aesthetics. The crazy pie chart shown above looks quite complicated and is probably enough to scare away a lot of users. However, the implementation is actually quite solid. Next to the graph is a simple list showing the types of data on your hard drive and how much space is being eaten up by them. All the information you need is in this list. It&#8217;s simple, straightforward and easy to understand. The visualization is there for visual thinkers like us designers who are crazy enough to favor this representation over a list. </p>
<p>Most importantly, the two representations of the data are linked in an interactive way. When you hover your mouse over the &#8220;Applications&#8221; line item, that part of the chart begins to glow. So even if you don&#8217;t remotely understand the chart at first, it will suddenly begin to make sense as you hover over each item in the list and see how the proportion of glowing space relates to other sections.</p>
<p>The lesson here is that eye candy isn&#8217;t for everyone. If you want to set your application apart as the one with crazy beautiful visualizations, go for it. But don&#8217;t neglect the users who would rather use Excel than Photoshop. Make sure your attractive graphics have a strong foundation in easy-to-use controls and understandable communication methods. </p>
<h2><a href="http://www.panic.com/transmit/">Transmit 4</a></h2>
<p>Transmit 4 is the latest update to the reigning patriarch of Mac FTP clients and represents one of the most significant aesthetic boosts to the application to date. I never thought I would drool over an FTP client but Transmit now has a ton of really nice screens, animations, buttons and more.</p>
<div class="tutorialimage"><a href="http://www.panic.com/transmit/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-6.jpg" alt="screenshot" width="510"/></a></div>
<p>The most noticeable tactic used here is increased contrast. FTP clients are notably bright and white; every screen, every list of files, nothing but white and, if you&#8217;re lucky, a little gray and/or blue. The folks at Panic decided to tackle this monotony with a number of really beautiful dark screens for setting up servers, navigating favorites, etc. </p>
<p>The important lesson here is that they really didn&#8217;t mess with the meat of the app too much. The file lists are still on a white background and function just like they always have. Anyone familiar with FTP software will be able to pick the app up and run with it immediately. Any time you want to update a UI to give it some visual flair, don&#8217;t be afraid to be extremely choosey about what parts do and don&#8217;t get updated. If you&#8217;re working with a product made popular by its simple functionality, keep it that way. Instead, take the time to focus on all the little details that really polish off a UI and make it feel like a major step up from the competition.</p>
<h2><a href="http://www.realmacsoftware.com/courier/">Courier</a></h2>
<p>Courier has to be the most beautiful tool on the planet for quickly sharing multimedia files using social media. Would I ever pay $20 for a Facebook image uploader? No way. Has this one made me seriously consider changing my mind? Yep.</p>
<div class="tutorialimage"><a href="http://www.realmacsoftware.com/courier/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-7.jpg" alt="screenshot" width="510"/></a></div>
<p>The lesson here is one I&#8217;ve discussed countless times in a web design context: visual metaphors rock. The first thing RealMac did was focus on core functionality. They made sharing files to all kinds of networks at once a ridiculously easy task powered by the drag and drop experience Mac users know and love. With an unbeatable workflow in place (always make sure to focus on content first!), they were able to wrap the whole thing in a beautiful and appropriate theme: the daily mail. This takes a fairly technological task and brings it into a very real and familiar experience for the user. Suddenly the mundane task of uploading files looks and feels like a virtual mail-sending video game where you can choose what envelope you want to use and where to send it. </p>
<h2><a href="http://agilewebsolutions.com/onepassword">1Password</a></h2>
<p>Open up Keychain Access on your Mac. This is a typical password manager, designed by none other than Apple inc. It&#8217;s quite usable but also quite boring. Now take a look at a very different visual approach to the same basic functionality in 1Password. </p>
<div class="tutorialimage"><a href="http://agilewebsolutions.com/onepassword"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-8.jpg" alt="screenshot" width="510"/></a></div>
<p>Quite the difference no? 1Password possesses a simply outstanding interface for managing your logins, passwords, form data, etc. I don&#8217;t know about you but this makes me question every single database application on my hard drive. Why has the norm become to make such plain presentations of database information? What if applications like Evernote (already one of the more attractive database apps out there) looked a little more like 1Password or Bento? Would that be so bad? I submit that it would not.</p>
<p>Great aesthetics don&#8217;t complicate usability, they improve it. Believe it or not, you can present tables, rows, cells and fields of information in a really attractive manner without adding so much superfluous fluff that it ruins the functionality. If you don&#8217;t believe me, download 1Password and give it a shot. </p>
<h2><a href="http://www.chocomoko.com/sweetfm">SweetFM</a></h2>
<p>In contrast to all this discussion of adding visual interest to your your interfaces, SweetFM, a wonderfully simple Last.fm client, does the exact opposite. Just take a look at how compact and attractive it is!  </p>
<div class="tutorialimage"><a href="http://www.chocomoko.com/sweetfm"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-9.jpg" alt="screenshot" width="510"/></a></div>
<p>Now, compare that screenshot you just saw to the official Last.fm client for Mac:</p>
<div class="tutorialimage"><a href="http://www.chocomoko.com/sweetfm"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-11.jpg" alt="screenshot" width="510"/></a></div>
<p>Admittedly, many people will like the official client better. It seems more robust and puts everything in front of you at once (a highly efficient approach). However, there&#8217;s definitely something to be said for drastic simplification. Back to a point that we made earlier, blindly following the UI conventions of a given category is no way to innovate. Sometimes you can snag a ton of users that no one else is targeting simply by stripping out everything but the absolute bare necessities. Take a page out of Chocomoko&#8217;s book, sometimes less really is more.</p>
<h2><a href="http://www.cockpitapp.com/index.html">Cockpit</a></h2>
<p>Cockpit is an awesome menu bar app that you can use to control all kinds of stuff on your Mac. It&#8217;s not only super functional though, it also happens to look pretty stellar.</p>
<div class="tutorialimage"><a href="http://www.cockpitapp.com/index.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/macinterfaces-10.jpg" alt="screenshot" width="510"/></a></div>
<p>In this case, I&#8217;m not sure where the developers are drawing their inspiration from. The typical textures are here: metal, glass and rubber. Yet, the iTunes controller above doesn&#8217;t look anything like iTunes and it sure as heck doesn&#8217;t look like any other menu bar app I&#8217;ve ever seen (it looks more like a Dashboard widget). There&#8217;s a lot to be said about drawing inspiration from all of the examples you&#8217;ve seen today, but always remember that there&#8217;s no substitute for blazing your own path and intentionally trying to be completely different than anything else you&#8217;ve seen before. </p>
<p>Pull up Photoshop, crank some music and spend a few hours dishing out ideas as they come to you. Instead of focusing on what&#8217;s been done elsewhere, try to discover what hasn&#8217;t been done and explore the possibilities with that goal in mind. </p>
<h2>Conclusion</h2>
<p>I hope the ten awesome applications above have both provided you with a few new apps for your Mac and taught you a thing or two about interface design. Mac developers and designers continually wow me with their ability to continually push the envelope for the level of beauty we expect from desktop applications. You guys are my heros.</p>
<p>Leave a comment below and let us know what you think of the interfaces above. Also be sure to point out any other new Mac apps you&#8217;ve come across that serve as an excellent example of UI design. </p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/software/10-fresh-mac-apps-with-beautiful-interfaces-and-what-we-can-learn-from-them/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Introduction to CSS3 &#8211; Part 4: User Interface</title>
		<link>http://designshack.net/articles/introduction-to-css3-part-4-user-interface/</link>
		<comments>http://designshack.net/articles/introduction-to-css3-part-4-user-interface/#comments</comments>
		<pubDate>Tue, 13 May 2008 16:22:02 +0000</pubDate>
		<dc:creator>David Appleyard</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[boxsizing]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[outline]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://localhost:8888/?p=191</guid>
		<description><![CDATA[This tutorial will be taking a look at some of the new ways you can manipulate user interface features in CSS3. But what do we mean by &#8220;user interface&#8221;? CSS3 brings some great new properties relating to resizing elements, cursors, outlining, box layout and more. We&#8217;re focusing on three of the most significant user interface [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will be taking a look at some of the new ways you can manipulate user interface features in CSS3. But what do we mean by &#8220;user interface&#8221;?</p>
<p>CSS3 brings some great new properties relating to resizing elements, cursors, outlining, box layout and more. We&#8217;re focusing on three of the most significant user interface enhancements in this tutorial.</p>
<p>The examples shown below can be seen at our CSS3 examples page. Many, however, can only be appreciated in the latest builds of various browsers:</p>
<p><a href="http://www.designshack.net/tutorialexamples/css3/css3examples.html" class="smallbox">View the live examples page</a></p>
<h2>Resizing</h2>
<p>The latest version of Safari has <a href="http://www.apple.com/safari/">a feature</a> which allows resizable text areas. This is a great addition and one I find myself using daily. CSS3 allows you to easily apply this to any element, eventually to become cross-browser compatible. The code is the <code>resize:both;</code> line:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.ui_resizable</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
resize<span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><img src="http://www.designshack.net/postimages/ui_resizable.png" alt="CSS3 Resizing" /></p>
<h2>Box Sizing</h2>
<p>The &#8216;box model&#8217; CSS3 module is one of the more extensive areas, and full information can be <a href="http://www.w3.org/TR/CSS2/box.html">found at the official specification</a>. The box sizing aspect allows you to define certain elements to fit an area in a certain way. For example, if you&#8217;d like two bordered boxes side by side, it can be achieved through setting box-sizing to &#8216;border-box&#8217;. This forces the browser to render the box with the specified width and height, and place the border and padding inside the box.</p>
<p>At present, additional prefixes are required to support this in all browsers &#8211; you can see the full list on the example page&#8217;s code. Here&#8217;s a basic possibility:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.area</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddccb5</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.boxes</span> <span style="color: #00AA00;">&#123;</span>
box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">50%</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#897048</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><img src="http://www.designshack.net/postimages/ui_boxsizing.png" alt="CSS3 Box Sizing" /></p>
<h2>Outline</h2>
<p>Setting an element outline is already available in CSS2, but in CSS3 includes the facility to offset the outline away from the element &#8211; by a value you define. It differs from a border in two ways:</p>
<ul>
<li>Outlines do not take up space</li>
<li>Outlines may be non-rectangular</li>
</ul>
<p>They can be created as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.ui_outline</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span> 
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">70px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#897048</span><span style="color: #00AA00;">;</span>
outline-offset<span style="color: #00AA00;">:</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><img src="http://www.designshack.net/postimages/ui_outline.png" alt="CSS3 Outline Offset" /></p>
<h2>In conclusion&#8230;</h2>
<p>These features aren&#8217;t revolutionary, and are not likely to cause a stir in the design community. It can&#8217;t be denied that they&#8217;re useful &#8211; in particular giving the reader the ability to resize elements.</p>
<p>The next article in this series will be looking more in-depth at one much more revolutionary feature of CSS3 &#8211; multi column text. Remember, to see live examples of these features, take a look at our <a href="http://www.designshack.net/tutorialexamples/css3/css3examples.html">CSS3 example page</a>.</p>
<h2>Other posts in the series</h2>
<ul>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-1-what-is-it">Introduction to CSS3 &#8211; Part 1: What is it?</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-2-borders">Introduction to CSS3 &#8211; Part 2: Borders</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-3-text-effects">Introduction to CSS3 &#8211; Part 3: Text Effects</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-4-user-interface">Introduction to CSS3 &#8211; Part 4: User Interface</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-5-multiple-columns">Introduction to CSS3 &#8211; Part 5: Multiple Columns</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-6-backgrounds">Introduction to CSS3 &#8211; Part 6: Backgrounds</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/introduction-to-css3-part-4-user-interface/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Object Caching 310/345 objects using disk: basic

Served from: designshack.net @ 2012-02-09 18:56:12 -->
