WaterBoy
WaterBoy

Reputation: 709

How/where do you add css code in angularJS

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

.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?

Upvotes: 0

Views: 135

Answers (2)

Icycool
Icycool

Reputation: 7179

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

By the user guide of material CSS, you should include these files in your 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>

Upvotes: 1

Sajeetharan
Sajeetharan

Reputation: 222582

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

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

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

DEMO

Upvotes: 2

Related Questions