It's impossible to do it using CSS only. You must use a CSS compressor such as SASS or LESS. Each application has an exclusive Bootstrap module and it can be launched using Bower or NPM.
After that you can call Bootstrap variables (check all the variables available in your_modules_path_here/bootstrap/_variables.scss), for example in SASS:
.your-custom-element {
background: $alert-info-bg;
}
Extra:
If you are using SASS, I suggest you to import some Bootstrap modules, instead of all Bootstrap stack. I've usually use this same method and it works fine.
In your main.scss
file, you must import all the dependencies and modules you want to use:
// some bootstrap modules
@import 'bootstrap/normalize';
@import 'bootstrap/variables';
@import 'bootstrap/mixins';
@import 'bootstrap/grid';
@import 'bootstrap/scaffolding';
@import 'bootstrap/responsive-utilities';
@import 'bootstrap/utilities';
@import 'bootstrap/modals';
@import 'bootstrap/forms';
@import 'bootstrap/input-groups';
@import 'bootstrap/tables';
After that, you should create your own _variables.scss
file to overwrite bootstrap SASS variables you want and prepend @import 'variables'
to the same main.scss
file
The Bootstrap sass module is very "varialized" and all the variables has a !default instruction, ready to be overwrited.
For example, in your custom _variables.scss
:
$default-font: "Lato", Verdana, Arial, sans-serif;
$link-color: #ef899e;
$body-bg: #f0f0f0;
$text-color: #666;
It will overwrite these variables and in the next SASS build, the output file will compile Bootstrap SASS module with your customizations.
To check all variables available in the Bootstrap module, you can see it in /node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_variables.scss
or bootstrap/_variables.scss
(inside your module manager path, if your are not using npm)
https://www.npmjs.com/package/bootstrap-sass
Hope it helps!