Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference bootstrap colors as a variable in css?

I'm trying to customize my bootstrap theme a bit. I'd like to do something like this in my own css file:

div {
background-color: @brand-warning;//or @body-bg or @dark-gray, etc
}

That is, Bootstrap has a warning color variable, but I'd like to access it. Anyway to do this?

Thanks

like image 202
user798719 Avatar asked Mar 03 '17 08:03

user798719


1 Answers

Bootstrap 4 defines CSS variables for theme colors that can be used in supporting browsers without compiling from SCSS: https://getbootstrap.com/docs/4.3/getting-started/theming/#css-variables

.my-warning {
    background-color: var(--warning);
}

There are also utility classes for text and background colors: https://getbootstrap.com/docs/4.3/utilities/colors/

<div class="bg-warning">Warning</div>

CodePen example

like image 152
afgrant Avatar answered Oct 29 '22 13:10

afgrant