How to change the default background color white to something else in twitter bootstrap

后端 未结 9 2035
再見小時候
再見小時候 2021-01-31 15:47

I am building a web application where I have set my default color to navy blue using css. But when i added the twitter bootstrap css\'s in my page I did not find my navy blue co

相关标签:
9条回答
  • 2021-01-31 16:19

    You can overwrite Bootstraps default CSS by adding your own rules.

    <style type="text/css">
       body { background: navy !important; } /* Adding !important forces the browser to overwrite the default style applied by Bootstrap */
    </style>
    
    0 讨论(0)
  • 2021-01-31 16:19

    I would not recommend changing the actual bootstrap CSS files. If you do not want to use Jako's first solution you can create a custom bootstrap style sheet with one of the available Bootstrap theme generator (Bootstrap theme generators). That way you can use 1 style sheet with all of the default Bootstrap CSS with just the one change to it that you want. With a Bootstrap theme generator you do not need to write any CSS. You only need to set the hex values for the color you want for the body (Scaffolding; bodyBackground).

    0 讨论(0)
  • 2021-01-31 16:20

    Bootstrap 4 provides standard methods for this, fully described here: https://getbootstrap.com/docs/4.3/getting-started/theming

    Eg. you can override defaults simply by setting variables in the SASS file, where you import bootstrap. An example from the docs (which also answers the question):

    // Your variable overrides
    $body-bg: #000;
    $body-color: #111;
    
    // Bootstrap and its default variables
    @import "../node_modules/bootstrap/scss/bootstrap";
    
    0 讨论(0)
  • 2021-01-31 16:20

    The colors changed due to the order of CSS files.

    Place the custom CSS under the bootstrap CSS.

    0 讨论(0)
  • 2021-01-31 16:24

    You can simply add this line into your bootstrap_and_overides.css.less file

    body { background: #000000 !important;}
    

    that's it

    0 讨论(0)
  • 2021-01-31 16:24

    You have to override the bootstrap default by being a bit more specific. Try this for a black background:

    html body {
        background-color: rgba(0,0,0,1.00);
    
    }
    
    0 讨论(0)
提交回复
热议问题