2013-07-31 43 views
6

我正在使用RoR創建一個月的Rails網站。這是styles.css.scss表單的代碼。它利用引導程序。我不確定爲什麼,儘管$ btnPrimaryBackground:綠色文本,按鈕顏色不會改變。有沒有人有任何想法或想法,爲什麼按鈕顏色不會改變?謝謝。使用引導程序更改按鈕顏色

$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; 
    } 
} 

回答

5

如果使用Bootsrap用量少,你可以簡單地做:

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

如果沒有,那麼你只需覆蓋要改變按鈕類顏色:

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

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

此外,因爲它看起來你想要改變按鈕顏色爲綠色,爲什麼不使用.btn-success類如下所示:

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

來源:Styling twitter bootstrap buttons

+0

我道歉 - 我將如何實現此代碼?我是一個初學者 – user2603139

+0

看看我發佈的新代碼。 – amb110395

+0

真誠的道歉 - 我不確定如何在我發佈的代碼中實現該功能... – user2603139

2

在引導3 buttonBackground不工作了,你必須使用button-variant(@color; @background; @border)這樣的:

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

您也可以使自己和.btn默認繼承。在SCSS中是這樣的:

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