简体   繁体   English

无法覆盖默认的引导CSS

[英]Can't override default bootstrap css

I can not override the default css. 我无法覆盖默认的CSS。 Any help? 有什么帮助吗?

HTML: HTML:

<link href="css/bootstrap.min.css" rel="stylesheet">

    <!--Custom CSS-->
<link fref="css/custom.css" rel="stylesheet">

CSS: CSS:

 .navbar ,.navbar-defualt {
    background-color: red;
    border-color: blue;
}

I have tried targeting .navar-custom and .navbar-inverse 我已经尝试定位.navar-custom和.navbar-inverse

EDIT: Your CSS is linked incorrectly. 编辑:您的CSS链接不正确。 Change the <link fref=""> to <link href=""> . <link fref="">更改为<link href=""> So just a little typo here which explains it all. 所以这里只是一个小错字,这说明了一切。

Just to make sure you've linked your custom.css to your HTML file correctly, try to change your navigation background color like following: 为了确保已将custom.css正确链接到HTML文件,请尝试更改导航背景颜色,如下所示:

.navbar-default {
   background-color: #00ffff !important;
}

If that does absolutely nothing at all, your CSS file is not linked to your HTML file and you should check what's wrong with the file path. 如果这根本没有任何作用,则说明您的CSS文件未链接到HTML文件,因此您应检查文件路径出了什么问题。

If it works, you should go for the .navbar-default only, since you don't necessarily need to override .navbar style properties when you're already doing it for the .navbar-default . 如果.navbar-default应使用.navbar-default ,因为当您已经对.navbar-default时, 不必覆盖.navbar样式属性

It's now safe to say it works and remove the !important markup , since it should work perfectly well without it. 现在可以肯定地说它可以工作并删除!important标记 ,因为没有它,它应该可以很好地工作。

If you need to override navbar-default class, then target same class. 如果您需要覆盖navbar-default类,则定位相同的类。 This is working. 可以了

Let me explain you this, in your code you are using navbar, navbar-default but those two classes are relevant to same class definition, so you do not need to use ','(comma). 让我向您解释一下,在您的代码中,您使用的是navbar,navbar-default,但是这两个类与同一类定义相关,因此您无需使用','(逗号)。 Instead of that use '.navbar.navbar-default'. 而不是使用'.navbar.navbar-default'。 This will give you the working CSS. 这将为您提供有效的CSS。

 .navbar-default { background-color: red; border-color: blue; } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM