Beyond the bare HTML

Sure the HTML is a foundation at is desirable to know how it works all it uses and expected and unexpected behaviour. But that is completely beyond the human capabilities. Fortunately the culture have its own memory and experience we can make use of.
As the web is basically the same, it shares the same structure over and over again if we want to write new website no matter if we are skilled or not, we would have to write it over and over again.
What a nonsense! It’s like make a new recording for every new mp3 file…..^$(&*{O*{)&)

Fortunately some people said to them selves “what is enough is enough” let’s step bit further and lets construct a next level foundation of elements we all code like sheep. As there are countless programmers there were countless such ideas but only some of the matured enough to be useable for others. One such foundation is the Bootstrap. Bootstrap has been introduced by people from Twitter which makes it super faithful and people start to expand on it immensely.
What this “next level” means? Ask Ninja.

Example – Minh’s web

For example Minh wants a website with a menu on top that will stay over there the whole time while the content freely scrolls underneath.

So he could write it like so:

That all looks good, now.
But what if we wanted it to behave the same on all browsers devices and expand its capabilities.
Are you sure that you can really guarantee that it’ll perform the same on all browsers and devices?
Do you really want to repeat your self in every project, do what have you done already?
Do you know all all the last browser changes and code standards?
..

I assume all questions were answered with “no”.

What Bootsrap does for you is that it gives you set of classes such as “.navbar-fixed-top” that turn the element with such class in to the fixed top menu. Only by giving the element a class, how cool is that?
There is even more. Form, tab, button classes you can reuse and tweak to your needs. But most importantly it gives you well thought out grid logic, you find in most website projects. Plus, it has a grate documentation which you can read anytime you are lost or simply don’t know how. Next super cool feature is also the fact that if you end up working on someoneelses project done in Bootstrap you know right away how it is meant because it follows the known logic. If the guy would make the website completely on his own without any reference you might end up completely lost not knowing what he meant by classes such as “.bigger” “._234item” “.wider” “.half_of_the_desert”,…

So gime me the Boostrap example!

In this example you see not just the menu but some content divided in to a grid that actually follows the Minhs intention.
To have a menu on top and a box of projects with some images etc.

Let’s get back to the menu case.
As you see there is actually no CSS defining the menu. If you copy&paste the code and create a file.html you’ll the menu magically sticked on top. How’s that?

If you look to the HTML HEAD you’ll se a link to externally located Bootstrap CSS. Since then we can use all the bootstrap logic like if it is ours. And so the common element with class “.navbar-fixed-top” turned to a fixed automagically without need to code.

There can be a book written on this topic, but for now be sure you have checked the Bootstrap website especially its grid system.

See the class “.col-md-6” that is half of 12 :) the default grid structure divided by 12. Seams stupid to you. Well just about the number 12?  It is a grate number divisible in to many variations such as “2*6” “3*4”, “4*3”, .. such number can by divided in to many whole numbers/portions which is what you need from grid. Plus it can be nested and multi-combined like (1*1 + 2*5 + 1*1) = 12 …I know Math ;) but Math makes the stuff beautiful .. Hmm I might touch that in next lesson.

 

Miloš’s Dog game

Another example we might be showing in here is a Milos’s dog game.
This is actually a perfect example of a the 5% web projects that does not need Bootstrap, even more it’ll be stupid to do so.

Milos want’s a build Mario Bros like a game where the character goes from left to right jump, eats, sniffs and all that stuff.
If you remember how such a games look like, the use a lot something that is called Parallax movement (see detailed explanation). Two pictures moving kind of independently to one another which gives a sense of artificial space of the scene. Buildings seams to move faster as they are closer to viewer compared to the sky which is obviously way further etc. Like in real life.
Lets start to build this game from scratch.

Test it your self.
What we have done here is that we use a sky picture as a whole body background and put inside a container with a part transparent picture of a desert with a tree. As the sky background is fixed and the container with the desert background can move it creates the Parallax trick. Isn’t it simple?
What we also added is a box for menu. The menu is flying over the desert and has two kinds of buttons (for now).

More tricks next time.

As always useful links:

Bootstrap, Bootstrap tutorial

Parallax scrolling

And again the frog CSS flex game.. super-useful and funny.

"This post is written for Prague College students. Feel free to explore the topic with us."