I’m trying to edit the looks and feel of the buttons in bootstrap so they look like the buttons that came in the FCC tutorial, but the files is a mess! This is the bootstrap.min.css files.
Does it look like this for anyone else, or only for me? How can I make sense of it, and is there a clean version available?
Yes, and you’ll probably have the situation where your css doesn’t take effect at all. In that case, open your Inspector (Dev tools) and look at the element in question. If your css is barred, that means that Bootstrap is stronger, that is, that they use more specific selectors. So just copy the selector and put it in your CSS file.
If you’re not sure about what I mean, look in the wiki, here or also this cheatsheet for CSS selectors.
Pro forum tip: You don’t need a third party website to host screenshots. You can actually drag and drop pictures that you want to share right into the text box. Like this:
It’s not a mess, it’s a minified version of CSS. It’s minified in order so that browser loads less resources and to load faster. Also to transfer less internet data. You will see a lot of .min.css and .min.js files as you develop web applications.
If you need a particular element from the Bootstrap framework, take it from the bootstrap.css file, everything is beautified there.
Note that bootstrap.min.css & bootstrap.css are exactly the same, only one is smaller and the other is larger (kilobytes).
I suggest you NEVER modify the Bootstrap CSS file, but simply attach your own stylesheet file (after the Bootstrap one) and make your changes there.
This way you can link the same unmodified Bootstrap CSS file to other projects, to which you could add different mods as you like.
Also, you could replace the Bootstrap CSS file with one from a different Bootstrap theme. This will work best if your original Bootstrap CSS file was never modified.
Hi, first @macloo is right you should never modify the Bootstrap file.
What I want to address here is the mess part. The file is looking as it should be because it went through the minification > Minification (also minimisation or minimization), in computer programming languages and especially JavaScript, is the process of removing all unnecessary characters from source code without changing its functionality.
In production mode this process allows you to reduce the file of JS and CSS. If you are developping you should try to use the non-minified version which does not have the min part. But it is not necessary because you should do it preferably as @macloo suggests.
I know that there have been a number of responses to your question, and linked tutorials that may have provided you with an answer… but I’ll chime in with the two most important aspects that I’ve learned in overriding Bootstrap.
First, in the <head> of your document, link to your custom CSS stylesheet after Bootstraps… or any other template CSS for that matter. The browser reads the the HTML from top to bottom. So your CSS should be ready to override the predefined styles.
However… the second and more important key to overriding Bootstrap is ensuring to target the element with at least the same specificity as they do. For instance:
Bootstrap adds their default button styles to an element with the .btn class. .btn { display: inline-block; padding: 6px 12px; margin-bottom: 0; etc... }
Then they add additional styles with classnames such as .btn-default. .btn-default { color: #333; background-color: #fff; border-color: #ccc; }
If you were to only target the <a> tag and try to add 20px of padding for instance, your CSS would be overridden because Bootstrap uses class names which has a higher specificity value than just a tag. Follow the recommendations above, and overriding any Bootstrap CSS should be a cinch from now on!
P.S.: And as others have pointed out, yes, minified CSS is a “mess”. But it’s a good mess and a mess for a reason.