Styling twitter bootstrap buttons

前端 未结 14 2686
庸人自扰
庸人自扰 2020-12-04 05:18

Twitter-Bootstrap buttons are awesomely beautiful. Try them out by scrolling over them

\"bootstrap

相关标签:
14条回答
  • 2020-12-04 05:48

    Basically, the buttons in Twitter Bootstrap are controlled in CSS by ".btn{}". What you have to do is go to the CSS file and find where it says "btn" and change the color settings. However, it's not as simple as just doing that since you also have to change what color the button changes into when you highlight it, etc. To do THAT, you have to look for other tags in CSS like ".btn:hover{}", etc.

    Changing it requires changing of the CSS. Here is a quick link to that file:

    https://github.com/twbs/bootstrap/blob/master/dist/css/bootstrap.css

    0 讨论(0)
  • 2020-12-04 05:49

    You can change background-color and use !important;

    .btn-primary {
      background-color: #003c79 !important;
      border-color: #15548b !important;
      color: #fff;
    }
    
    .btn-primary:hover {
      background-color: #4289c6 !important;
      border-color: #3877ae !important;
      color: #fff;
    }
    
    .btn-primary.focus, .btn-primary:focus {
       background-color: #4289c6 !important;
       border-color: #3877ae !important;
       color: #fff;
    }

    0 讨论(0)
  • 2020-12-04 05:53

    For Bootstrap (at least for version 3.1.1) and LESS, you can use this:

    .btn-my-custom {
        .button-variant(@color; @background; @border)
    }
    

    This is defined in bootstrap/less/buttons.less.

    0 讨论(0)
  • 2020-12-04 05:54

    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]; }
    
    0 讨论(0)
  • 2020-12-04 05:57

    Or try http://twitterbootstrapbuttons.w3masters.nl/. It creates css for buttons based on html color input. Add the css after the bootstrap css. It provides three styles of buttons (light, dark and spin).

    0 讨论(0)
  • 2020-12-04 05:58

    Here is a very easy and eficient way: add in your CSS your class with the colors you want to apply to your button:

    .my-btn{
        background: #0099cc;
        color: #ffffff;
    }
    .my-btn:hover { 
      border-color: #C0C0C0; 
      background-color: #C0C0C0; 
    }
    

    and add the style to your bootstrap button or link:

    <a href="xxx" class="btn btn-info my-btn">aaa</a>
    
    0 讨论(0)
提交回复
热议问题