Showing posts with label HTML5. Show all posts
Showing posts with label HTML5. Show all posts

Tuesday, May 14, 2013

Responsive webdesign


2013 is the year of responsive web design (RWD). But what is responsive web design and how can we use it?
Not even five years ago almost everyone was browsing the Internet with laptops or a desktop computer. The life of a web developer was relatively easy, from 800x600 till 1900x1440 screen sizes you needed to cover but not much more. You could create a totally static page with just one set of layout rules and everybody would be happy, and every browser would display the page the way you made it.

Today however, people browse from thousands of different devices, from phones to tablets, Eee pads, laptops, computers and even iPods. All of which have different screen sizes. This drastically changed the web development approach, introducing media queries and a new way of designing websites: responsive web design.

What is responsive web design?

Responsive web design is a design approach with which we try to create one website for all devices. The basic elements of responsive web design include a fluid grid concept, flexible images and media queries.

Fluid grids

A fluid grid is a grid of elements usually divs, that all have proportional sizes (percentages instead of pixels). When all the elements of the grid have their width and or height proportional to the size of the screen it scales on all devices. This is already a nice thing, though we should also make sure that the content of the grid is resizes as well.

Flexible images

​If there is something to be flexible then this is in the first place the images we use. Flexible images are images with their width in percentages instead of pixels. Usually they have their width to 100% of their container. This way the image will never run outside its boundaries. Drawbacks can be though that the image becomes too large on HD screens, resulting in a pixelated appearance. Or the image becomes so small on small screens that it becomes useless.

Media queries

With media queries in CSS you can apply specific CSS rules only when certain conditions apply. You can for example create a media query on Max-Width. 
@media screen and (max-width: 600px) { img{ width: 100%; }}
Now the image on this site will appear 100% of the container width if the screen width is smaller or equal 600px. If the screen is larger, the image will not have the 100% rule. This way we can for instance make a web page with an image and a few lines of text appear on small screens like:

And on big screens like:
This we can do with the Media query max-width, and by setting "float:left;" for the image.
We can also use media queries for a whole css stylesheet. To do so we need to add the media query declaration in the head of the html file.
<link rel="stylesheet" media="screen and (max-width: 600px)" ...
We can do many more media queries so to adapt our design for all kind of devices.
On this site from CSS-Tricks you can find a nice list.

Text in responsive designs

Text in responsive websites can give problems. For instance the text might be too big for the container that holds it. To solve those problems we can make sure that the containers height varies depending on the text, but sometimes this is not what you want. If you want to keep the restrictive height the only solution is cutting the text nicely and making sure the whole text can be seen in another way. A solution could be a "more" button for example that enlarges the container when clicked.

Clipping the text we can achieve by applying the following css rules:

overflow:hidden;
text-overflow:ellipsis;

The first rule makes sure the text is not visible outside the container, the second line makes sure that the clipping of the text is rendered like "...".
This can also be handy with titles in headers for example. If the title on a mobile phone header is too big,  it is usually not a problem whether the text is clipped. If the text is not clipped however it will run out of the header and might break the style of the page below.

Wednesday, October 31, 2012

Are html5/javascript apps the future?

Nowadays html5 / javascript apps can be found a lot on the internet.
Also on mobile platforms as Android and iOS, html5 apps appear in the markets more and more often. The question is are these webapps the future or are they too limited and slow?


Webapps for mobile phones.
We can make webapps for mobile phones with the help of Phonegap/Cordova. Phonegap gave us the ability to convert our webapps into applications for mobile phones. Although applications made this way are noticable slower then native made applications, and they cannot acces all native features (yet), they are developed easily and can be used on all platforms without the need to rewrite code.

With libraries like jQuery Mobile you can create a nice looking app for Android and iPhone without the need to know anything about Objective-C or Android Java. All you have to do is write a web application in your favorite editor, test it in the major browsers and then with the help of Phonegap convert it into a native application.

So for mobile phones webapps are doing better and better. There are some advantages and some disadvantages. Lets create a little list.

Advantages:
  •  Easy to develop
  •  No knowledge needed in Java / other native language
  •  Crossplatform

Disadvantages:
  •  Slower
  •  Less native features

Now lets look at the disadvantages. Slower many people say, yes this is true a native application is faster then a html5 app and this will always be the case, you cannot make a faster app then doing it native. Though, new phones have faster and faster cpu and load html5 apps so fast that you almost see no difference with native apps.

Less native features, it is true that even by using phonegap you cannot access all native features from every device with the same html5 / javascript code. But, luckily here we can use phonegap plugins.
A large collection of already made plugins can be found here.
With phonegap plugins you can basically connect your javascript code with native code. This makes the options endless! Although it seems that the whole effect of crossplatform html5 apps is gone when you still need to implement native plugins. For now though this is a good solution for the few things that are not available yet in html5/javascript apps.

Webapps for desktops
In desktops webapps are not common and well used at the moment rather then by using a browser to go to the webapp. With the coming of Windows 8 this will already change quite a bit. Windows 8 will support webapps and even let users sell them in there kind of appstore. It is easy to convert your own webapp for Windows 8 with Visual Studio 2012 for windows 8.

Now I hear you say, If I don't have windows 8 (and there are also many reasons not to have it), I can not execute my webapp? You can!You can create an executable for windows, Linux or Mac OSX in seconds with appJS. This little tool simulates a localhost browser with your webapp inside. You can specify settings like title, screen size and others in the javascript file in the zip folder you can dowload from their website.

So now we can make webapps for internet, mobile phones / tablets and desktop PC's!
Are webapps the future? I think they are, although sometimes you cannot go without native.

We ourselves are working on a totally crossplatform product with an approximate release date of Januari 2013. Check our site to find out more.