当前位置: 动力学知识库 > 问答 > 编程问答 >

html - What is the correct way to "overwrite" bootstrap colors? (and optionally other CSS selectors)

问题描述:

Searching on topic how to customize the original bootstrap CSS I mainly found power tools and generators what are emit a "patched" bootstrap.css to use instead the original.

I am very beginner in bootstrap, so first I would like to see clear the best practices before I invest hundreds of workhours to do something dumb and not recommended thing.

My question: Is this the way? I mean editing (automatically or manually) the bootstrap.css. Sounds not good for me, I am hoping I missed something.

Is there any alternative way, say creating a tiny mycustom.css and only define the differences there. Could anyone point out how to redefine just the standard colors?

网友答案:

Best option if you`re are beginner is to generate a new bootstrap.css with the oficial generator http://getbootstrap.com/customize/ and so you also could test changes in other Bootstrap variables. I think that overwrite css properties with your own CSS file can be painful sometimes...

Best option (need time to learn) is import Bootstrap as LESS (not CSS) and then create your own variables.less file, where you will define values for all Bootstrap variables that you want to overwrite.

网友答案:

Don't edit bootstrap.css.

Instead create your new css file and add new values in that file and make sure that this new file is loaded after bootstrap.css .

网友答案:

For small changes include your own .css file after including bootstrap, overwriting the css components of bootstrap. This is what bootstrap advises (check bootstrap components page)

body { padding-top: 70px; } Make sure to include this after the core Bootstrap CSS.

网友答案:

This website demonstrates exactly how to override Bootstrap's CSS without doing naughty things like using !important in your own CSS files (which should be avoided). You simply create a new custom.css file and add in your overriding styles there.

I would not directly edit the LESS/SASS Bootstrap files.

分享给朋友:
您可能感兴趣的文章:
随机阅读: