2016-09-21 162 views
-1

在名为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元素。任何帮助,将不胜感激。谢谢。

+0

尝试使用'!important'关键字:https://www.smashingmagazine.com/2010/11/the-important-css-declaration-how-and-when-to-use-it/ – Nestoraj

+0

重要的应该是'如果你在第一次之后包括第二名,那么你就是必须的。 – Roberrrt

+0

@Nestoraj你说的只是包括在second.css CSS值中重要吗? – user1871869

回答

2

负载second.css后first.css

<head> 
    <link rel="stylesheet" type="text/css" href="first.css"> 
    <link rel="stylesheet" type="text/css" href="second.css"> 
</head> 

然后在第二个CSS样式那些重置none。但好像边框颜色不能有none值,以便您可以尝试transparent

.ng-invalid :not(.ng-valid)>.form-control input { 
    border-color: 'transparent'; 
    -webkit-box-shadow: 'none'; 
      box-shadow: 'none'; 

} 

.ng-invalid :not(.ng-valid)>.form-control:focus input { 
     border-color: 'transparent'; 
    -webkit-box-shadow: 'none'; 
      box-shadow: 'none' 
} 
0

尝试second.css

+0

这不提供问题的答案。要批评或要求作者澄清,请在其帖子下方留言。 - [来自评论](/评论/低质量帖/ 13743082) – Jost

+0

@Jost这**是答案**。请阅读并阅读[本文](http://meta.stackoverflow.com/questions/287563/youre-doing-it-wrong-a-plea-for-sanity-in-the-low-quality-posts-队列)和[本文](http://meta.stackexchange.com/questions/225370/your-answer-is-in-another-castle-when-is-an-answer-not-an-answer)我们应该在LQP审查队列中删除哪些答案,我们应该只是冷静下来,我们应该放弃什么。 –

0

使用none价值box-shadow财产只是新的属性添加到second.css覆盖的CSS样式first.csshttps://jsfiddle.net/vLhuowss/

.myDiv { 
 
\t height: 100px; 
 
\t width: 100px; 
 
\t background-color: red; 
 
} 
 

 
.myDiv { 
 
\t background-color: blue; 
 
}
<div class="myDiv"></div>