Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS中的类与继承的属性冲突_Css_Twitter Bootstrap - Fatal编程技术网

CSS中的类与继承的属性冲突

CSS中的类与继承的属性冲突,css,twitter-bootstrap,Css,Twitter Bootstrap,我最近在我的项目中添加了bootstrap,效果很好,但我遇到了一个CSS问题 在将引导添加到我的项目之前,我添加了以下CSS类: .inlineItem.label { font-weight: bold; margin-right: 20px; width: 220px; } 引导有自己的.label .label { display: inline; pad

我最近在我的项目中添加了bootstrap,效果很好,但我遇到了一个CSS问题

在将引导添加到我的项目之前,我添加了以下CSS类:

        .inlineItem.label {
            font-weight: bold;
            margin-right: 20px;
            width: 220px;
        }
引导有自己的.label

.label {
       display: inline;
       padding: .2em .6em .3em;
       font-size: 75%;
       font-weight: 700;
       line-height: 1;
       color: #fff;
       text-align: center;
       white-space: nowrap;
       vertical-align: baseline;
       border-radius: .25em;
      }
我想没问题,我的类和我希望它应用的地方比引导类更具体,所以它会忽略它。问题是它仍然使用引导标签类,只是从更具体的类中添加了其他属性

我想这就是CSS应该如何工作的


除了重命名我的类或将引导标签类可能覆盖的属性设置为inherit之外,是否没有办法告诉它不要使用引导库中的类?

您应该检查是否在声明引导之前先声明.css文件:

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

只需更改.label。将.label类更改为.mylabel,然后尝试。。
.label {
       display: inherit;
       padding: inherit;
       font-size: inherit;
       font-weight: inherit;
       line-height: inherit;
       color: inherit;
       text-align: inherit;
       white-space: inherit;
       vertical-align: inherit;
       border-radius: inherit;
}