Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

nicholas maddren
nicholas maddren
12,793 Points

Bootstrap Question

Just been watching a Bootstrap workshop on Tree House. One thing I am struggling to understand...

Here is an example:

So let's say I have a div tag and I have set the class to the one bootstrap is providing me with to make a certain change. How would I go by making other CSS changes to that div element? If I use that class across quite a few elements I will be making changes that I don't want to make?

Thanks any light on this would be great :)

2 Answers

Paul Jankowski
Paul Jankowski
2,698 Points

Hello Nicholas,

You can add more than one class to an element. That way, bootstrap will provide its styling, while you can still use your own!

Here is an example:

<div class="bootstrap-class custom-class"></div>

All you need to do is add a space between multiple class declarations on an element.

Hope this helps! Paul Jankowski

jdh
jdh
12,334 Points

Just to add an example to Paul's description:

<div class="col-xs-12 other"></div>

where "col-xs-12" is a bootstrap defined and "other" is another your own specific css declaration.

Also its probably best to make sure you own css styling page is at the bottom or below the bootstrap page or else it may not be rendered in the browser. Lastly, another best practice I've found is not to make specific edits to the bootstrap.css file but rather just override it in my own style.css file. For instance, I don't like the bootstrap declaration of:

.row { margin: -15px 15px; }

so in my style.css, I generally add

.row { margin: 0px !important;}

hope this helps :)