From 3aa29b00f256a5fc69b559a63d007b8970e35ffa Mon Sep 17 00:00:00 2001
From: 林正祥 Now that we've got our basic application structure set up and started displaying something useful, let's switch gears and spend an article looking at how Angular handles styling of applications. 現在,我們已經建立了基本的應用程式結構,並加入了內容,接著我們就要來對應用程式進行樣式的調整,透過本篇文章來學習如何使用樣式點綴我們的 Angular 應用程式。 The Angular CLI generates two types of style files: Angular CLI 會產生兩種類型的樣式檔: Depending on whether you are using a CSS preprocessor, the extension on your CSS files can vary.
-Angular supports plain CSS, SCSS, Sass, Less, and Stylus. 根據您是否使用 CSS 預處理器,CSS 檔案的副檔名也會有所變化,Angular 支援純 CSS、SCSS、Sass、Less、以及 Stylus。 In 在
-
預備知識:
- Familiarity with the core HTML, CSS, and JavaScript languages, knowledge of the terminal/command line.
+ 熟悉 HTML、CSS 以及 JavaScript 的核心,了解 終端機/命令列(terminal/command line)相關知識。
學習目標:
- To learn how to style an Angular app.
+ 學習如何使用樣式點綴 Angular 應用程式。
Adding some style to Angular
+增加樣式到 Angular 中
-
-
-styles.css
: In the src
directory, the styles in this file apply to your entire application unless you specify styles at the component level.styles.css
:在 src
目錄底下,除非你在元件層級指定樣式,否則這個檔案的樣式會套用到整個應用程式。src/styles.css
, paste the following styles:src/styles.css
中,貼上以下樣式:body {
font-family: Helvetica, Arial, sans-serif;
@@ -108,10 +106,9 @@ Angular supports plain CSS, SCSS, Sass, Less, and Stylus.
The CSS in src/styles.css
apply to the entire application, however, these styles don't effect everything on the page.
-The next step is to add styles that apply specifically to the AppComponent
.
在 src/styles.css
中的 CSS 會應用在整個應用程式,但是這些樣式不會影響到頁面上所有內容。下一步將要新增專門讓 AppComponent
套用的樣式。
In app.component.css
, add the following styles:
在 app.component.css
中,增加以下樣式:
body { color: #4d4d4d; @@ -170,11 +167,11 @@ ul { list-style: none; }-
The last step is to revisit your browser and look at how the styling has updated. Things now make a bit more sense.
+最後,回到瀏覽器看看樣式更新之後的效果,現在看來比較有美感了。
-Now that our brief tour of styling in Angular is done with, let's return to creating our app functionality. In the next article we will create a proper component for to-do items, and make it so that you can check, edit, and delete to-do items.
+我們對 Angular 樣式的簡介也告一個段落了,接下來讓我們開始幫應用程式加上功能吧。在下一篇文章中,我們將建立一個適用於待辦事項的元件,並使其成為可以讓您標示完成、編輯以及刪除待辦事項。