Twitter-Bootstrap buttons are awesomely beautiful. Try them out by scrolling over them
But they are limited in colors.
Is there any way I could change the base color of the button while keeping the beautiful hover-over effect that bootstrap has made so beautiful and effortless?
I am completely unaware of what the css/javascript looks like that twitter uses to maintain those effects.
Use the . btn-sm class in Bootstrap to create a small button.
To create a large button, use the . btn-lg class in Bootstrap.
I found the simplest way is to put this in your overrides. Sorry for my unimaginative color choice
.my-btn { //@include button-variant($btn-primary-color, $btn-primary-bg, $btn-primary-border); @include button-variant(red, white, blue); }
Bootstrap 4 Alpha SASS Example
.my-btn { //.button-variant(@btn-primary-color; @btn-primary-bg; @btn-primary-border); .button-variant(red; white; blue); }
Bootstrap 3 LESS Example
.my-btn { //@include button-variant($btn-primary-color, $btn-primary-bg, $btn-primary-border); @include button-variant(red, white, blue); }
Bootstrap 3 SASS Example
.btn-primary { //.buttonBackground(@btnBackground, @btnBackgroundHighlight, @grayDark, 0 1px 1px rgba(255,255,255,.75)); .buttonBackground(red, white); }
Bootstrap 2.3 LESS Example
.btn-primary { //@include buttonBackground($btnPrimaryBackground, $btnPrimaryBackgroundHighlight); @include buttonBackground(red, white); }
It will take care of the hover/actives for you
From the comments, if you want to lighten the button instead of darken when using black (or just want to inverse) you need to extend the class a bit further like so:
.my-btn { // @include button-variant($btn-primary-color, $btn-primary-bg, $btn-primary-border); $color: #fff; $background: #000; $border: #333; @include button-variant($color, $background, $border); // override the default darkening with lightening &:hover, &:focus, &.focus, &:active, &.active, .open > &.dropdown-toggle { color: $color; background-color: lighten($background, 20%); //10% default border-color: lighten($border, 22%); // 12% default } }
Bootstrap 3 SASS Lighten Example
You can overwrite the colors in your css, for example for Danger button:
.btn-danger { border-color: #[insert color here]; background-color: #[insert color here]; .btn-danger:hover { border-color: #[insert color here]; background-color: #[insert color here]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With