在名为first.css一个文件,有很多CSS的,我需要它,但这是CSS,我不需要像在这里看到的一块,但似乎是越来越应用到我的input
:如何用默认配置覆盖CSS?
first.css:
.ng-invalid :not(.ng-valid)>.form-control {
border-color: #b94a48;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.ng-invalid :not(.ng-valid)>.form-control:focus {
border-color: #953b39;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
}
我基本上不想让CSS不适用于我的输入形式,所以我做这样的事情:
second.css:
.ng-invalid :not(.ng-valid)>.form-control input {
//I simply want the default CSS to apply, and not that from first.css
}
.ng-invalid :not(.ng-valid)>.form-control:focus input {
//I simply want the default CSS to apply, and not that from first.css
}
second.html:
<form style="margin-top: 10px" name="configurationForm" ng-class="{'submitted': submitted}" ng-submit="createConfiguration(configurationForm.$valid)" novalidate>
<div class="form-group row" ng-class="{'has-error': configurationForm.name.$invalid && !configurationForm.name.$pristine && submitted }">
<label for="name" class="col-xs-1 col-form-label">Name</label>
<div class="col-xs-11">
<input name="name" style="font-size: 10px; border-radius: 4px !important;" type="text" class="form-control" placeholder="Name" ng-model="configuration.name" required />
</div>
</div>
... <More form-control> ...
</form>
有没有办法简单地防止first.css的CSS从应用?我只是想要默认的配置(不管它们是什么)应用,而不是上面这就是为什么我留下了空的second.css
css元素。任何帮助,将不胜感激。谢谢。
尝试使用'!important'关键字:https://www.smashingmagazine.com/2010/11/the-important-css-declaration-how-and-when-to-use-it/ – Nestoraj
重要的应该是'如果你在第一次之后包括第二名,那么你就是必须的。 – Roberrrt
@Nestoraj你说的只是包括在second.css CSS值中重要吗? – user1871869