Start learning with our library of video tutorials taught by experts. Get started

Up and Running with Bootstrap 2

Overriding Bootstrap core CSS


From:

Up and Running with Bootstrap 2

with Jen Kramer

Video: Overriding Bootstrap core CSS

Finally, the video you all have been waiting for: how do you override the core CSS in Bootstrap? Well, there are two possible ways that you can do this. I am on the getbootstrap.com website, and I've clicked on the Customize link, and this is the page where you can customize Bootstrap to do exactly what you need it to do and nothing more. So, you can choose exactly which components you want to include. We talked a little bit about the Scaffolding, much of the rest of this we haven't talked about yet, but these are JavaScript-driven widgets that I'm going to cover in a couple of videos, some of the styling that's in CSS you can choose to include it or not, you can choose to include specific plug-ins that we rely on jQuery, you can customize these variables.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Up and Running with Bootstrap 2
2h 38m Beginner Oct 12, 2012

Viewers: in countries Watching now:

Bootstrap is a free web development tool from Twitter that, with a little bit of CSS and JavaScript experience, makes building websites quick, intuitive, and fun. Author Jen Kramer explores its 12-column grid layout; typography and icon libraries; fully functional components like nav bars, buttons, and tabs; and much more. This course also shows how to add JavaScript extras like dropdown menus, modal windows, and photo carousels.

Topics include:
  • Understanding the difference between default and fluid grids
  • Nesting with fluid grids
  • Creating a thumbnail gallery
  • Adding block quotes and lists of text
  • Incorporating images and icons
  • Adding breadcrumb navigation and pagination
  • Using tabs and pills navigation
  • Making the nav bar responsive with JavaScript
  • Adding dropdown menus to the nav bar, tabs, and pill
Subjects:
Web CMS Blogs Responsive Design Web Design
Software:
Bootstrap
Author:
Jen Kramer

Overriding Bootstrap core CSS

Finally, the video you all have been waiting for: how do you override the core CSS in Bootstrap? Well, there are two possible ways that you can do this. I am on the getbootstrap.com website, and I've clicked on the Customize link, and this is the page where you can customize Bootstrap to do exactly what you need it to do and nothing more. So, you can choose exactly which components you want to include. We talked a little bit about the Scaffolding, much of the rest of this we haven't talked about yet, but these are JavaScript-driven widgets that I'm going to cover in a couple of videos, some of the styling that's in CSS you can choose to include it or not, you can choose to include specific plug-ins that we rely on jQuery, you can customize these variables.

Bootstrap makes use of the less framework, and you can type in different values for these things. So the easiest one to understand is here under Colors. So what exact shade of blue would you like to have where blue occurs inside of your document, what exact shade of green and so forth? So you can customize all these variables and type in your own values and then customize here and download by clicking on the big honking button at the bottom of the page that will download exactly what it is that you want to have for your website.

However, there are some major downsides to customizing your Bootstrap Installation this way, particularly where the CSS is concerned. First of all, in the course of preparing for this video, Bootstrap released two new versions. I started working with Bootstrap 2.0.4, and just yesterday 2.1.1 was released, so obviously these new releases are happening all the time. If you want to update your website to the latest version of Bootstrap, right now what you would do is simply download the latest version, replace the existing CSS and JavaScript files with the new versions that you would download from the Bootstrap site, which is great until you realize that any customization that you've done to bootstrap.css or bootstrap-responsive.css will instantly be lost, because you'll overwrite those files with the new ones that you've downloaded.

So you'll either need to now as part of that process keep track of where all those customizations are and retype them in here on the screen, or you'll have to keep track of what they are and re-enter them when you upgrade your version of Bootstrap, and that's just too much work for me. I can't remember what I've changed and what I haven't changed. So, I think a far better approach is to create a custom stylesheet and put any changes that you're going to include there. Anything you're going to override or any additional styling that you're going to include, put it all in that stylesheet, and that will make your website so much more maintainable.

It'll be so easy to upgrade the latest version of Bootstrap, because then you'll just copy those new files in over the old files and your customizations are all still intact. So, let me show you how to do that process now. Back here in Dreamweaver, I'm going to go ahead and I'm going to create a new document, so File > New, and this time it's going to be a stylesheet. So I'm going to pick Stylesheet from my Page Types over here and say Create, and it's going to create a blank stylesheet document for me. Because this is just a proof of concept thing, I'm going to make a really quick change here.

I am going to go ahead and change the body background color to a lovely shade of green, so I'm going to say background-color is bada66, and I'm going to go ahead and save that, File > Save. So I'm going to go to Desktop, to my Bootstrap folder, to my CSS folder, and I'm going to save this as custom.css, so that is my custom stylesheet.

Now the next thing I have to do is attach it to the document I have been working on, so here's my schedule.html, which is the document I've been working on in this chapter. I'm going to click here just after the style sheet for bootstrap-responsive, and I'm going to insert my stylesheet here. So, over here on the right side of the screen, if you click on the Link icon here inside of the CSS Styles palette and you choose the Custom Style Sheet here from the list, go ahead and say OK. It'll go ahead and write in the code to include your custom style sheet right here inside of your document.

Again, you want it to occur last in the string of style sheets, because remember, anything that you put in your custom style sheet you're going to want to override what comes before it, and so if you put this custom.css stylesheet somewhere further up the line, closer to the title tag in the code that I'm working with here, it may not necessarily override the default styling from Bootstrap. Okay, once you've got that in place, File > Save, we can go ahead and take a look at this in Firefox, and if I Refresh the page that I'm working on, you can now see that we have a lovely shade of green behind our text here, and the icons that we put it in, in the previous lesson you can see that we have a nice dark icon, we also have a white icon, we have some white here associated with our block quote, and if we scroll on down the page a little farther, this image here that had that class applied to it, image-polaroid, you can see that it has a nice white stripe around in addition to that thin light gray stripe that goes around it as well.

So that is how you add custom styles to your document. Make sure you put them in a separate style sheet, call it whatever you like, I usually call mine custom.css because it's pretty clear what that is, and then make sure you link it to your document after any other style declarations that are on your page so that it'll override things correctly.

Find answers to the most frequently asked questions about Up and Running with Bootstrap 2.


Expand all | Collapse all
Please wait...
Q: I am trying to create the image carousels shown in this course, and they are not functioning properly. The custom.css file seems to be missing from the exercise files and I think this is the reason. Can you provide it?
A: custom.css isn't created until the carousel indicators are added. However, these styles have to do with the way the indicators look, and nothinghas to do with the way the carousel functions.
 
Are you sure you're working with Bootstrap 2.x? You download that from here: 
http://getbootstrap.com/2.3.2/. The carousel changed radically between Bootstrap 2.x and Bootstrap 3, and this course might not work with version 3.
Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Up and Running with Bootstrap 2.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked