There is light at the end of the tunnel and it is NOT Chuck Norris holding a flashlight. Finally, someone fixed CSS. This is a library made by Mark Otto and Jacob Thornton – normal people – developers like you and me, and they did great!
These two guys working on Twitter were suffering the same problems we have been dealing with in HTML and CSS. Fed up with the situation, they decided to build a base CSS Sheet designed to be imported into any website. It makes every front-end development work 4x’s easier.
Besides, Bootstrap gives you a dozen of new elements that you would normally want to use but don’t actually exist in CSS+HTML: The Bootstrap components.
One of the broken things in CSS is the way that layouts work – working with float, display and position sucks. This is how Bootstrap solved it:
Bootstrap creators replicated the same concept that
<tables> had, but instead of using tables, they used
<div> (boxed containers). They can’t create their own HTML tags because that will require a new HTML version and would make Bootstrap incompatible with current browsers. Tags must stay the same – that’s why they decided to override the
<div> default behaviors with classes.
Bootstrap has divided the width of the screen in
12 slots – each of them with 8,33% of the total width of the row. The size of 1 column, can be between 1 and 12 slots.
On the flip side, columns were made to live within the rows (just like what happens between
<tr>). You always need to open a row before opening a column. All columns in a row must always add up to a maximum of 12 slots.
Just like we did in the Layout chapter of the course, let’s create one page with 2 big sections: one sidebar on the right and one main content on the left.
It’s very easy to decide how your website will render in different screen sizes; when you add each column into the rows you need to assign a class with the following format:
|Means that this element should behave like a Bootstrap column.||Means that it is specified for only for the devices with a "medium" sized screen.||Specifies how many slots I want this column to take (remember you can take a max of 12 slots per row).|
☝Bootstrap device sizes: Phones Big-phone/small-tablet Tablets Desktops Extra-large desktops Nothing sm md lg xl
☝ Note: if you don’t specify the screen size (ex. by using 'sm', 'md', or 'xl'), the website will be rendered for mobile phones by default.
We are going to set the layout (using the sm, md and lg column classes) for two rows in all the devices at the same time:
We already know the basic HTML5 skeleton that any website needs to have. Now you just have to add a few lines in your skeleton to make it "Bootstrap compatible":
Remember, Bootstrap is just a stylesheet. That’s why it is very simple to include in your website. You use the
🔗 Here you can find some great Bootstrap files to get you started.
HTML is so basic that it only has a few tags – we know that already. But when you browse the web today you see a different thing: websites today have menus, icons, load-bars, navbars, labels, etc. Where are those tags? None of those tags are defined in HTML!
Every developer has to fake these additional elements every time they create a new website. They have to do everything from scratch, and it takes a lot of time.
When you import Bootstrap into your website, you will have a new set of components at your disposal. This is just a small part of those elements:
This is so popular that it’s in the menu of 99% of all websites. It normally has the logo of the company and a series of links – depending on each website’s business logic.
Here is an example of how a NavBar may look on a website:
This is probably the most used Bootstrap component, every website has a few cards because they are ideal for listing items in a beautiful way. Some examples of the Card used can be:
Here is an example of how a "The Card" may look on a website:
Everyone hates a modal, it is super annoying, always asking you to subscribe to a newsletter! 🙂
Here is how a modal looks by default on Bootstrap.
Bootstrap official documentation is amazing! We don’t need to start copying and pasting all their posts. Please visit the following and focus on reading these topics:
☝ Bootstrap versions & download
Bootstrap has many versions, always check if you are using the latest version of Bootstrap on your project, here you can find all the available versions: https://getbootstrap.com/docs/versions/.
We recommend using a CDN to import bootstrap in your HTML like this one: https://www.bootstrapcdn.com/
If you are migrating your project to a newer Bootstrap version remember to check its documentation.
The most efficient way to learn: Join a cohort with classmates like yourself, live streamings, coding jam sessions, live mentorships with real experts and keep the motivation.
From zero to getting paid as a developer, learn the skills of the present and future. Boost your professional career and get hired by a tech company.
Start a career in data science and analytics. A hands-on approach with interactive exercises, chat support, and access to mentorships.
Keep your motivation with this 30 day challenge. Join hundreds of other developers coding a little every day.
Start with Python and Data Science, Machine Learning, Deep Learning and maintaining a production environment in A.I.