Custom css overridden by Bootstrap in browser

谁说胖子不能爱 提交于 2019-12-11 23:36:14

问题


I have my stylesheet directory set up like this

stylesheets
    bootstrap.min.css
    style.css

In my style.css, I want to edit the pre tag like this:

pre {
    background-color: #d9edf7;
    border: #d9edf7;
    color: navy;
}

However, this is not getting picked up in the browser. It seems like the browser is going with the styles in bootstrap.min.css. This is what it looks like in Chrome's inspector tools when I hover over the block of pre tag:

So how do I get it to use my custom css instead?


回答1:


You have to make sure you include your custom CSS after the Bootstrap CSS, like the following:

<head>
    <!-- don't include your custom CSS here! -->
    <link rel="stylesheet" type="text/css" href="bootstrap.css">
    <link rel="stylesheet" type="text/css" href="custom.css">
    <style>
        pre {
            background-color: #d9edf7;
            border: #d9edf7;
            color: navy;
        }
    </style>
</head>



回答2:


Place style.css after bootstrap.min.css, so style overrides bootstrap.



来源:https://stackoverflow.com/questions/38622595/custom-css-overridden-by-bootstrap-in-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!