Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 :)