sgx
sgx

Reputation: 1317

Using Bootstrap to Change Button Color

I'm using RoR to make a one-month rails website. This is the code from the styles.css.scss sheet. It utilizes bootstrap. I am unsure as to why but the button color does not change despite the $btnPrimaryBackground: green text. Does anyone have any ideas or thoughts on why the button color doesn't change? Thanks.

$baseFontFamily: Oxygen;
@import url(http://fonts.googleapis.com/css?family=Oxygen);


$navbarBackgroundHighlight: white;
$navbarBackground: white;
$btnPrimaryBackground: green;

@import 'bootstrap';
body{
    padding-top: 60px;
}

@import 'bootstrap-responsive';

.navbar-inner{
    @include box-shadow(none !important);
    border: 0;
}

.footer{
    margin-top: 50px;
    color: $grayLight;
    a{
        color: $gray;
    }
}

Upvotes: 6

Views: 35481

Answers (3)

Mike
Mike

Reputation: 459

You can also make your own and inherit from .btn-default. In SCSS like this:

.btn-custom { @extend .btn; @extend .btn-default; color: #6EA81A; }

Upvotes: 0

Eric Marcos
Eric Marcos

Reputation: 2707

In Bootstrap 3 buttonBackground doesn't work anymore, you have to use button-variant(@color; @background; @border) like this:

.btn-custom {
    .button-variant(@custom-color, @custom-color-bg, @custom-color-border);
}

Upvotes: 2

amb110395
amb110395

Reputation: 1545

If you are using Bootsrap with LESS, you can simply do:

.btn-primary {
  .buttonBackground(@yourColor, @yourColorDarker); //(button, hover)
}

If not then you simply override the button class which you want to change color:

.btn-warning { background-color: Your color; } //button

.btn-warning:hover { background-color: Your color; } //hover

Furthermore, since it appears you want to change the button color to green why dont you use the .btn-success class like so:

<%= button_tag "Hello", :class => "btn btn-success" %>

Source: Styling twitter bootstrap buttons

Upvotes: 5

Related Questions