Thursday 18 November 2010

Use of Bokeh

Bokeh are those pictures we see of blurred spots of light. They are a very useful texture, common among good web designs. Below is an example of how they can be used.

See demo.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Use of Bokeh</title>
<style type="text/css">
*
{
margin:0;
padding:0;
}
html, body
{
font-family:Sans-serif;
font-size:0.96em;
background:#000000;
color:#CCCCCC;
}
#container
{
margin:0 auto;
width:920px;
}
#navigation, #content, #highlights, #footer
{
display:block;
}
#navigation, #footer
{
height:40px;
}
#navigation
{
text-align:right;
}
#navigation a
{
color:#CCCCCC;
text-align:center;
text-decoration:none;
width:80px;
height:40px;
padding-top:10px;
   padding-left:10px;
   padding-right:10px;
display: inline-block;
}
#navigation a:hover
{
background:url(http://farm5.static.flickr.com/4081/4995562250_2dfe171a8d_t.jpg) repeat-x;
}
h1, h2
{
font-family: Georgia, Serif;
font-weight:lighter;
font-style:italic;
}
h1
{
font-size:4em;
}
h2
{
text-align:left;
font-size:3em;
}
#content
{
background:#000000 url(http://farm5.static.flickr.com/4153/5000536973_2d2634aba3_b.jpg) no-repeat right top;
margin-left:20px;
margin-right:20px;
padding:10px;
color:#FFFFFF;
}
#content p
{
text-align:justify;
width:400px;
}
#highlights
{
margin-left:10px;
}
.highlight
{
float:left;
width:260px;
margin:20px;
}
.highlight p
{
text-align:justify;
}
#footer
{
clear:both;
}
#footer p
{
text-align:center;
padding-top:10px;
}
</style>
</head>
<body>
<div id="container">
<div id="navigation">
<a href="#" class="subMenu">home</a>
<a href="#" class="subMenu">products</a>
<a href="#" class="subMenu">services</a>
<a href="#" class="subMenu">about</a>
</div>
<div id="content">
<h1>Important Header</h1>
<h2>Less important header</h2>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.</p>
</div>
<div id="highlights">
<div class="highlight">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
</div>
<div class="highlight">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
</div>
<div class="highlight">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
</div>
</div>
<div id="footer"><p>This could be a very long footer.</p></div>
</div>
</body>
</html>

Tuesday 16 November 2010

Using css3pie with on HTML5 for cross browser effects

I have been using css3pie from http://css3pie.com/ for some time now. In order to run the test below, you will have to download it. You could put it in a scripts folder as I have but it doesn't matter. The example below contains a few elements which will make it work cross browser.
Firstly, I have added the html5.js reference at the top.
Secondly, I have reset the * and body values.
Thirdly, I have use em insted of px.
Finally, I switched the gradient around on the -pie-background call.
Enjoy!

See demo.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS3pie test</title>
<!--[if IE]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<style>
*
{
margin:0;
padding:0;
border:0;
}
body
{
font-family:Sans-serif;
color:#FFFFFF;
font-size:1em;
line-height:140%;
}
section#borderRadiusExample
{
background:#6BC2E8;
width:10em;
padding:0.62em;

/* rounded corners */
border-radius:0.62em;
-moz-border-radius:0.62em;
-webkit-border-radius:0.62em;

/* Shadow */
box-shadow:0.3em 0.3em 0.3em #CCCCCC;
-moz-box-shadow:0.3em 0.3em 0.3em #CCCCCC;
-webkit-box-shadow:0.3em 0.3em 0.3em #CCCCCC;

/* Linear gradient */
background-image:-moz-linear-gradient(90deg, #6BC2E8, #ABDEF3);
background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, from(#6BC2E8), to(#ABDEF3));
-pie-background:linear-gradient(90deg, #ABDEF3, #6BC2E8);

behavior:url('scripts/PIE.htc');
}
</style>
</head>
<body>
<section id="borderRadiusExample">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
</section>
</body>
</html>

Monday 15 November 2010

HTML5 tags I am currently using

Why would I write this article?
It's just to give you a flavour of the HTML5 features I have found to be reliable and how I use them. There is a simple template below, but essentially they are <header></header>, <footer></footer>, <section></section>, <article> </article> and <aside></aside>.
Of course, you may be thinking, he's not using proper HTML5 html and meta tags. That's because the new ones are not currently accepted by the W3C Validators.

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>HTML5 example</title>
<style type="text/css">
body
{
 font-family:Sans-serif;
}
#mainPage, header, footer
{
 margin:0 auto;
 width:30.8em;
 *width:30em;
}
#leftContent
{
 float:left;
}
#rightContent
{
 float:right;
}
footer
{
 clear:both;
}
</style>
<!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->
</head>
<body>
<header>
    <h1>My header</h1>
</header>
<section id="mainPage">
    <section id="leftContent">
        <article>Article 1</article>
        <article>Article 1</article>
    </section>
<aside id="rightContent">Content on the aside</aside>
</section>
<footer>Footer</footer>
</body>
</html>

Tuesday 9 November 2010

Pixel to em calculator

These days we need to use the most flexible means of sizing elements in our web content. Our websites have to cope with different devices, different resolutions, different user preferences, accessibility, etc...

Step forward em. This can, not only be used for font sizes, but layout too. We are used to sizing elements of our pages using pixels. To be more flexible, and get in the swing of thinking about em instead of pixels, in the early stages we need a converter. Now of course, IE certainly early versions of it need to be covered, if we want our pages to be rendered consistently. For this we should put an * before our properties.

The example below, provides you with a converter and an example of how to use it.

See demo.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pixel to em calculator</title>
<style type="text/css">
body
{
font-family:Sans-serif;
}
#mainPage
{
margin:0 auto;
width:30.8em;
*width:30em;
}

</style>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1");
google.load("jqueryui", "1");
</script>
<script>
jQuery(function( $ )
{
$("#button").click(function()
{
$('#emlVal').val(parseFloat($('#pixelVal').val()*0.0625).toFixed(2));
$('#emForIEval').val(parseFloat($('#emlVal').val()*1.1).toFixed(2));
});
});
</script>
</head>
<body>
<div id="mainPage">
Pixel value<br /><input type="text" name="pixelVal" id="pixelVal" /><br />
Em value<br /><input type="text" name="emVal" id="emlVal" /><br />
Em for IE value<br /><input type="text" name="emForIEval" id="emForIEval" /><br />
<input type="submit" value="Submit" id="button" />
</div>
</body>
</html>

Monday 8 November 2010

jQuery to split your strings into classes

This next example simplifies, but pays reference to some excellent work done on http://daverupert.com/2010/09/lettering-js/. I have taken this idea but used it to create the same class across all the letters in my title. You'll be able to see why when you copy the code into a file of your own. Essentially , in this case, I have put boxes around each letter to give you an idea as to what you can do.

See demo.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Splitting Letters</title>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1");
google.load("jqueryui", "1");
</script>
<script>
$.fn.spanTheChars = function()
{
var returnString = '';
$(this.text().split('')).each(function()
{
returnString += '<span class="chars">'+this+'</span>';
});
$(this).empty().append(returnString);
}
jQuery(function( $ )
{
$('h1').spanTheChars();
});
</script>
<style type="text/css">
body
{
font-family:Sans-serif;
font-size:62.5%;
}
h1
{
text-align:center;
font-size:2em;
text-transform:uppercase;
color:#FFFFFF;
}
.chars
{
display:block;
float:left;
width:2.8em;
min-height:2em;
background:#5CCCCC;
margin:0.2em;
padding-top:1em;
}
</style>
</head>
<body>
<h1>Split Title</h1>
</body>
</html>

Font combinations test #2

As promised the example below is a good way to test out which web safe font combinations are going to work. You simply need to comment out the fonts you don't want to use from the font-family tags in the CSS. In the case of the headers, you should also consider changing the font-weight to bold. Once you are happy. You need to think about colours. I get my colour combinations from the excellent http://colorschemedesigner.com.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Font Combination #2</title>
<style>
body
{
/* font-size:62.5%; */
font-size:80%;
}
h1, h2, h3, h4
{
font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif;
font-family:'Times New Roman', Times, serif;
font-family: Georgia, Serif;
font-family:‘Lucida Console’, Monaco, monospace;
font-family:'Courier New', Courier, monospace;
font-weight:normal;   
}
h1, h2
{
text-transform:uppercase;
}
h1
{
font-size:5em;   
}
h2
{
font-size:4em;   
}
h3
{
font-size:3em;   
}
h4
{
font-size:2em;   
}
p, blockquote, strong, ul, ol, input, small, span
{
font-family:Impact, Charcoal, sans-serif;
font-family:Tahoma, Geneva, sans-serif;
font-family:Century Gothic, sans-serif;
font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
font-family:'Arial Black', Gadget, sans-serif;
font-family:'Arial Narrow', sans-serif;
font-family:Verdana, Geneva, sans-serif;
font-family:Copperplate / Copperplate Gothic Light, sans-serif;
font-family:Gill Sans / Gill Sans MT, sans-serif;
font-family:'Trebuchet MS', Helvetica, sans-serif;
font-family:Arial, Helvetica, sans-serif;
font-family:‘Lucida Console’, Monaco, monospace;
font-family:'Courier New', Courier, monospace;
font-style:normal;
font-variant:normal;
font-weight:normal;
letter-spacing:0.1em;
}
blockquote
{
text-indent:-0.8em;
font-size:1.5em; 
p
font-size:1.25em;
margin-top:1.25em;
margin-bottom:1.25em;   
input
font-size:1.0em; 
small
font-size:0.75em; 
}
span
{
font-style:italic;
}
strong
{
font-variant:small-caps;
}
p.justified
{
text-align:justify;
}
</style>
</head>
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<p>Paragraph. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
<blockquote>Blockquote. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</blockquote>
<strong>Strong. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</strong>
<ul>
<li>Unordered list. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
<li>Vestibulum auctor dapibus neque.</li>
</ul>
<ol>
<li>Ordered list. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
<li>Vestibulum auctor dapibus neque.</li>
</ol>
<input type="text" name="name" id="name" value="input" tabindex="1" /><br />
<small>Small. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</small>
<span>Span. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</span>
<p class="justified">Paragraph justified. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
</body>
</html>

Font combinations test #1

The example below is a good way to test out which web safe font combinations are going to work. You simply need to comment out the fonts you don't want to use from the font-family tags in the CSS. In the case of the headers, you should also consider changing the font-weight to bold. Once you are happy. You need to think about colours. I get my colour combinations from the excellent http://colorschemedesigner.com. I'm going to follow this blog up with a similar example, this time reversing the sans-serif and serif fonts.

See demo.

<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset="UTF-8">
<title>Font Combination #1</title>
<style>
body
{
/* font-size:62.5%; */
font-size:80%;
}
h1, h2, h3, h4
{
font-family:Impact, Charcoal, sans-serif;
font-family:Tahoma, Geneva, sans-serif;
font-family:Century Gothic, sans-serif;
font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
font-family:'Arial Black', Gadget, sans-serif;
font-family:'Arial Narrow', sans-serif;
font-family:Verdana, Geneva, sans-serif;
font-family:Copperplate / Copperplate Gothic Light, sans-serif;
font-family:Gill Sans / Gill Sans MT, sans-serif;
font-family:'Trebuchet MS', Helvetica, sans-serif;
font-family:Arial, Helvetica, sans-serif;
font-family:‘Lucida Console’, Monaco, monospace;
font-family:'Courier New', Courier, monospace;
font-weight:normal;
}
h1, h2
{
text-transform:uppercase;
}
h1
{
font-size:5em;
}
h2
{
font-size:4em;
}
h3
{
font-size:3em;
}
h4
{
font-size:2em;
}
p, blockquote, strong, ul, ol, input, small, span
{
font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif;
font-family:'Times New Roman', Times, serif;
font-family: Georgia, Serif;
font-family:‘Lucida Console’, Monaco, monospace;
font-family:'Courier New', Courier, monospace;
font-style:normal;
font-variant:normal;
font-weight:normal;
letter-spacing:0.1em;
}
blockquote
{
text-indent:-0.8em;
font-size: 1.5em;
}
p
{
font-size:1.25em;
margin-top:1.25em;
margin-bottom:1.25em;
}
input
{
font-size:1.0em;
}
small
{
font-size:0.75em;
}
span
{
font-style:italic;
}
strong
{
font-variant:small-caps;
}
p.justified
{
text-align:justify;
}
</style>
</head>
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<p>Paragraph. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
<blockquote>Blockquote. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</blockquote>
<strong>Strong. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</strong>
<ul>
<li>Unordered list. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
<li>Vestibulum auctor dapibus neque.</li>
</ul>
<ol>
<li>Ordered list. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
<li>Vestibulum auctor dapibus neque.</li>
</ol>
<input type="text" name="name" id="name" value="input" tabindex="1" /><br />
<small>Small. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</small>
<span>Span. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</span>
<p class="justified">Paragraph justified. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
</body>
</html>