如何/在angularJS中添加css代码?

时间:2021-07-05 23:23:41

I am trying to build a dialog using AngularMaterial and in the demo it has css code:

我正在尝试用AngularMaterial构建一个对话框,在演示中它有css代码:

.dialogdemoBasicUsage #popupContainer {
  position: relative; 
}

.dialogdemoBasicUsage .footer {
  width: 100%;
  text-align: center;
  margin-left: 20px;
}

.dialogdemoBasicUsage .footer, .dialogdemoBasicUsage .footer > code {
  font-size: 0.8em;
  margin-top: 50px; 
}

.dialogdemoBasicUsage button {
  width: 200px; 
}

.dialogdemoBasicUsage div#status {
  color: #c60008; 
}

.dialogdemoBasicUsage .dialog-demo-prerendered md-checkbox {
  margin-bottom: 0; 
}

In my angularJS project - where do I put this code? do i create a new .css file and then reference it and do I have to put anything around it?

在我的angularJS项目中——我把代码放在哪里?我要创建一个新的。css文件,然后引用它,我需要在它周围添加什么吗?

2 个解决方案

#1


2  

It is the same way how you do it in normal HTML application.

在普通的HTML应用程序中也是如此。

Add the css code to a file named style.css , refer it inside

将css代码添加到名为style的文件中。css,把它放在里面。

<head>
  <title>To Do List</title>
  <link href="style.css" rel="stylesheet" />
</head>

DEMO

演示

#2


1  

In normal use case you should include the CSS file come with the library.

在正常使用情况下,应该包括CSS文件和库。

By the user guide of material CSS, you should include these files in your HTML

根据材料CSS的用户指南,您应该将这些文件包含在HTML中。

<html lang="en" >
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Angular Material style sheet -->
  <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
</head>
<body ng-app="BlankApp" ng-cloak>
  <!--
    Your HTML content here
  -->  

  <!-- Angular Material requires Angular.js Libraries -->
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>

  <!-- Angular Material Library -->
  <script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>

  <!-- Your application bootstrap  -->
  <script type="text/javascript">    
    /**
     * You must include the dependency on 'ngMaterial' 
     */
    angular.module('BlankApp', ['ngMaterial']);
  </script>

</body>
</html>

<!--
Copyright 2016 Google Inc. All Rights Reserved. 
Use of this source code is governed by an MIT-style license that can be in foundin the LICENSE file at http://material.angularjs.org/license.
-->

If you need further modification on top of their CSS, make a new CSS file and include it below angular-material CSS file in <head>

如果您需要对其CSS进行进一步修改,请创建一个新的CSS文件,并将其包含在的angular-material CSS文件下。

#1


2  

It is the same way how you do it in normal HTML application.

在普通的HTML应用程序中也是如此。

Add the css code to a file named style.css , refer it inside

将css代码添加到名为style的文件中。css,把它放在里面。

<head>
  <title>To Do List</title>
  <link href="style.css" rel="stylesheet" />
</head>

DEMO

演示

#2


1  

In normal use case you should include the CSS file come with the library.

在正常使用情况下,应该包括CSS文件和库。

By the user guide of material CSS, you should include these files in your HTML

根据材料CSS的用户指南,您应该将这些文件包含在HTML中。

<html lang="en" >
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Angular Material style sheet -->
  <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
</head>
<body ng-app="BlankApp" ng-cloak>
  <!--
    Your HTML content here
  -->  

  <!-- Angular Material requires Angular.js Libraries -->
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>

  <!-- Angular Material Library -->
  <script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>

  <!-- Your application bootstrap  -->
  <script type="text/javascript">    
    /**
     * You must include the dependency on 'ngMaterial' 
     */
    angular.module('BlankApp', ['ngMaterial']);
  </script>

</body>
</html>

<!--
Copyright 2016 Google Inc. All Rights Reserved. 
Use of this source code is governed by an MIT-style license that can be in foundin the LICENSE file at http://material.angularjs.org/license.
-->

If you need further modification on top of their CSS, make a new CSS file and include it below angular-material CSS file in <head>

如果您需要对其CSS进行进一步修改,请创建一个新的CSS文件,并将其包含在的angular-material CSS文件下。