A grid system divides the screen into multiple rows and columns that can be used to create various types of layouts. With Bootstrap, to set the maximum width of the page content according to the screen width, you have to use a container. All the rows and columns should be placed inside a container to ensure proper alignment and padding.
Continue reading »
Horizontal and vertical centering with CSS
One of the most common tasks while designing web pages is centering elements both vertically and horizontally.
To center a block (div, p, h1, and so on) horizontally, the only thing you have to do is to apply a margin
auto to it. For example,
1 2 3 4 |
.horizontal-align { margin:0 auto; width:200px; } |
You have to take into account that a width is necessary.
Continue reading »
Debugging HTML & CSS alignment issues
Many times it is very annoying when you are designing a page and suddenly you notice that something is not not properly aligned.
In these cases, it can be helpful to outline elements on the page to figure out how they are being rendered in relation to one another. One solution would be to write your own css class, such as the following:
1 |
* { box-shadow: inset 0 0 0 1px red } |
However, a better and more convenient way is to use the Web Developer browser extension available for Chrome, Firefox and Opera.
For example, in the following image you can see all the block elements outlined using the Firefox version of the extension:
Of cource, you can always resort to Firebug plugin or/and Chrome DevTools. Another good idea might be to use a validation tool such as the W3C markup validation service, the W3C CSS validator or CSS Lint.
Bootstrap: Hello World!
In order to create our first html page, Hello World!, using Bootstrap, we will go to the official Bootstrap website at http://getbootstrap.com/ and download the lastest 3.x.x version. Then will extract the archive and copy the following folders: css, fonts and js. Our project will have these folders and all of the main html archive at the same level that these folder.
Continue reading »