Dec 23 2008

Basic layouts with the Blueprint CSS framework

Ever wanted an easy way to make a website look good from the start without taking your focus away from programming? With Blueprint CSS you can set up a basic wireframe, with nice typography in just minutes!

Blueprint CSS is a CSS framework made up of pre-defined classes. Styles are controlled not by editing CSS, but by the way classes are assigned to page elements. Blueprint CSS works by creating a 24 column grid that you can size and position elements on by assigning certain classes.

In just 15 minutes, including designing the banner in Photoshop and writing this blog post, I was able to build a nearly-complete web page. With a few lines of our own CSS we’ll be able to have a great looking page.

Page generated with Blueprint CSS

To get to this point, you’ll need to download and install Blueprint CSS. To install, just drag the “blueprint” folder into your site root. Then all you need to do is create your html file with the appropriate classes defined, which you can find below. Remember to link the CSS files in the head of your page or it won’t work.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Blueprint Test</title>
<link media="screen, projection" type="text/css" href="blueprint/screen.css" rel="stylesheet">
<link media="print" type="text/css" href="blueprint/print.css" rel="stylesheet">
<!--[if IE]>
<link media=”print” type=”text/css” href=”blueprint/ie.css” rel=”stylesheet”>
<![endif]–>
</head>
<body>
<div class=”container”>
<div class=”span-24″ id=”header”>
<img src=”images/header.jpg” alt=”Blueprint CSS - Example”/>
</div>
<div id=”navContain” class=”span-24″>
<ul id=”nav”>
<li><a href=”index.html”>Home</a></li>
<li><a href=”about.html”>About</a></li>
<li><a href=”contact.html”>Contact</a></li>
</ul>
</div>
<div id=”news” class=”span-6″>
<h2>News</h2>
12.23.08 - Tested Blueprint CSS
</div>
<div id=”content” class=”span-18 last”>
<h2>Blueprint CSS</h2>
<p>
This div is set to span 18 of the 24 grid columns and show up as the last column in the row.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc viverra massa et erat auctor porttitor. Nunc in turpis. Suspendisse pulvinar cursus sem. Ut luctus dui vel nulla. Nulla
rutrum adipiscing ante. Proin sed felis id ante ultrices semper. Etiam aliquet sollicitudin arcu. Integer vehicula ultrices eros. Aliquam sed neque eget ligula aliquet blandit. Sed
rutrum scelerisque ipsum. Donec et arcu. Praesent luctus. Curabitur ullamcorper auctor arcu.
</p>
</div>
<div id=”footer” class=”span-24″>
&copy; 2008 mysite.com
</div>
</div>
</body>
</html>

Now we’ll create a new CSS file for our site, and link it to our page. I like to call mine styles.css, and since Blueprint doesn’t use that name, we will go ahead and use it. In that file, we will spruce up the navigation, and footer.


#navContain ul{
background-color:#7090C9;
left:-18px;
position:relative;
width:950px;
}
#navContain ul li{
display:inline;
list-style-type:none;
padding:10px;
}
#navContain ul li a{
text-decoration: none;
color: #FFFFFF;
}
#footer{
color: #ffffff;
text-align: center;
background-color:#7090C9;
}

Page made pretty by our CSS

There you have it! A simple, great looking page in no time.

Live Example


Dec 16 2008

Adding design elements to your website with jQuery.

Every action has an equal and opposite reaction. This statement has been true since the dawn of time, but not since the dawn of the web. Static web pages no longer keep today’s tech-savvy, smart phone addict at bay. People love interactivity, whether it be with other people, computers, or their iPhone. If you have something on your website that is dynamic and exciting, people will keep coming back. People will keep coming back, and they will show other people who will also keep coming back. An exciting and dynamic website will drive more traffic and keep users coming back for more.

So how does one incorporate these interactive pieces into a website?

A great way to add some eye catching effects to your website is by using jQuery’s slide animation. This is a simple jQuery script that will allow you to toggle the visibility of site elements. This ain’t your grandad’s visibility toggle, it actually uses animation to show or hide a chosen element.

Heres How to do it:

Download jQuery and place it on your web site with any other javscript files you might have. Then we’re going to create a javaScript file that will contain all of your jquery scripts to make exciting animations.

First we declare the name of our class

var MYSITE = {};

Then create our constructor function, right now this does nothing, since we have no functions to call when our page loads. The red part is our “list”, which will contain our trigger and target, this will most likely be different for you. The green part is our trigger, or the item we click on to expand or collapse the target. Finally, you guessed it, the blue part is the target. This is the element that we will be able to toggle the visibility of.

$(function() {

jQuery.MYSITE.compactor(’div#page div#content div#body div#post-3.post div.entry‘, ‘p‘, ‘div‘);

}

Finally we create our class

jQuery.MYSITE = {

compactor : function ( list, trigger, target ){

$(list).find(target).css({display :”none”});
$(list).find(target+":first").css({display: "block"});/*This will show the first target when the page loads. This line may be removed if you would like all of the targets hidden at the same time.*/

$(list).find(trigger).addClass(" link").hover( function () {
$(this).addClass(" linkOver");

}, function () {
$(this).removeClass("linkOver");
}).click( function () {
$(list).find(target+":visible").not(this).slideUp("def");
$(list).find(trigger).not(this).removeClass("linkOn");
$(this).addClass(" linkOn").next(target+":hidden").slideDown("def");
return(false);
});

}

}

Last but not least don’t forget to add jQuery and the file you created to your pages. it should look something like this:

<script type="text/javascript" src="jslib/jquery-1.2.6.min.js">
</script>
<script type="text/javascript" src="jslib/scripts.js"></script>