- Cache pages for offline usage
HTML5 introduces a great feature, offline caching. Basically, this feature allows you to tell the client browser to cache some pages so your visitor will be able to view it again, even if he’s not connected to the Internet.
Caching pages is pretty easy. The first thing to do is to add the following to your site
.htaccess
file:AddType text/cache-manifest .manifest
Once done, you can create a file named, for example,
offline.manifest
, with the following directives:CACHE MANIFEST CACHE index.html style.css image.jpg
And finally, link your
.manifest
file to your html document:
That’s all, and your page will now be cached if the client browser supports this technology.
- Server-side JavaScript
Since the mid-90′s, JavaScript has been a very popular client-side language for web developers. But nowadays, JavaScript is becoming more and more used on the server side. Why? Because now we have powerful server-side JavaScript environments such as Jaxer, Node.js and Narwhal.
The code belows demonstrate how to create a simple Hello World using Node.js.
var sys = require("sys"); sys.puts("Hello World!");
- CSS animations
Most modern browsers are now supporting CSS animations. Yes, CSS are now allowing you to create some simple animations, without the help of a client-side programming language such as JavaScript.
The following example shows how to make a background color change. As you can see, we have (for now) to use some proprietary properties such as
-moz-keyframes
.#logo { margin: 15px 15px 0 15px; background: red; float: left; /* Firefox 4+ */ -moz-animation-name: colour-change; -moz-animation-timing-function: linear; -moz-animation-iteration-count: infinite; -moz-animation-duration: 30s; /* Webkit */ -webkit-animation-name: colour-change; -webkit-animation-timing-function: linear; -webkit-animation-iteration-count: infinite; -webkit-animation-duration: 30s; } @-moz-keyframes colour-change { 0% { background: red; } 33% { background: green; } 66% { background: blue; } } @-webkit-keyframes colour-change { 0% { background: red; } 33% { background: green; } 66% { background: blue; } }
- Font resizing with REMs
CSS3 introduces a few new units, including the rem unit, which stands for “root em”. If this hasn’t put you to sleep yet, then let’s look at how rem works.The em unit is relative to the font-size of the parent, which causes the compounding issue. The rem unit is relative to the root—or the html—element. That means that we can define a single font size on the html element and define all rem units to be a percentage of that.html { font-size: 62.5%; } body { font-size: 1.4rem; } /* =14px */ h1 { font-size: 2.4rem; } /* =24px */
- CSS3 media queries
With the rise of mobile devices, and on the other hand, of very wide displays, creating a website that looks great in both big and small devices is definitely a challenge for web designers and developers. Happily, the CSS3 specification have a new feature which allow web developers to define styles for a specific display size only.For example, the code below show how to apply a specific style only if the client display is smaller than 767px.@media screen and (max-width:767px){ #container{ width:320px; } header h1#logo a{ width:320px; height:44px; background:url(image-small.jpg) no-repeat 0 0; } }
No comments:
Post a Comment