Skip to content

Commit eb5a675

Browse files
committed
Vietnamese version
1 parent 015a055 commit eb5a675

File tree

1 file changed

+84
-84
lines changed

1 file changed

+84
-84
lines changed

README.md

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
# Airbnb CSS / Sass Styleguide
22

3-
*A mostly reasonable approach to CSS and Sass*
3+
*Một cách tiếp cận hợp lý nhất với CSS và SASS*
44

5-
## Table of Contents
5+
## Mục lục
66

7-
1. [Terminology](#terminology)
8-
- [Rule Declaration](#rule-declaration)
7+
1. [Thuật ngữ](#terminology)
8+
- [Khai báo](#khai-báo)
99
- [Selectors](#selectors)
10-
- [Properties](#properties)
10+
- [Thuộc tính](#thuộc-tính)
1111
1. [CSS](#css)
12-
- [Formatting](#formatting)
13-
- [Comments](#comments)
14-
- [OOCSS and BEM](#oocss-and-bem)
12+
- [Quy cách](#quy-cách)
13+
- [Chú thích](#chú-thích)
14+
- [OOCSS BEM](#oocss--bem)
1515
- [ID Selectors](#id-selectors)
1616
- [JavaScript hooks](#javascript-hooks)
17-
- [Border](#border)
17+
- [Đường viền](#đường-viền)
1818
1. [Sass](#sass)
19-
- [Syntax](#syntax)
20-
- [Ordering](#ordering-of-property-declarations)
21-
- [Variables](#variables)
19+
- [Cú pháp](#cú-pháp)
20+
- [Thứ tự](##sắp-xếp-các-khai-báo-thuộc-tính)
21+
- [Biến](#biến)
2222
- [Mixins](#mixins)
23-
- [Extend directive](#extend-directive)
24-
- [Nested selectors](#nested-selectors)
23+
- [Mở rộng directive](#extend-directive)
24+
- [Selectors lồng nhau](##selectors-lồng-nhau)
2525
1. [Translation](#translation)
2626

27-
## Terminology
27+
## Thuật ngữ
2828

29-
### Rule declaration
29+
### Khai báo
3030

31-
A “rule declaration” is the name given to a selector (or a group of selectors) with an accompanying group of properties. Here's an example:
31+
Một "khai báo" là tên gọi của một selector (hoặc một nhóm các selectors) với một nhóm các thuộc tính. Dưới đây là ví dụ:
3232

3333
```css
3434
.listing {
@@ -39,7 +39,7 @@ A “rule declaration” is the name given to a selector (or a group of selector
3939

4040
### Selectors
4141

42-
In a rule declaration, “selectors” are the bits that determine which elements in the DOM tree will be styled by the defined properties. Selectors can match HTML elements, as well as an element's class, ID, or any of its attributes. Here are some examples of selectors:
42+
Trong một khai báo, "selectors" là phần sẽ xác định xem phần tử nào trong DOM sẽ được style bởi các thuộc tính xác định. Selectors có thể tương ứng với các phần tử HTML, cũng như class hay ID của phần tử, hoặc bất kì thuộc tính nào của nó. Dưới đây là ví dụ về selectors:
4343

4444
```css
4545
.my-element-class {
@@ -51,9 +51,9 @@ In a rule declaration, “selectors” are the bits that determine which element
5151
}
5252
```
5353

54-
### Properties
54+
### Thuộc tính
5555

56-
Finally, properties are what give the selected elements of a rule declaration their style. Properties are key-value pairs, and a rule declaration can contain one or more property declarations. Property declarations look like this:
56+
Thuộc tính là một cặp khóa-giá trị, và một khai báo có thể chứa một hoặc nhiều khai báo của thuộc tính. Cách khai báo của thuộc tính như sau:
5757

5858
```css
5959
/* some selector */ {
@@ -64,19 +64,19 @@ Finally, properties are what give the selected elements of a rule declaration th
6464

6565
## CSS
6666

67-
### Formatting
67+
### Quy cách
6868

69-
* Use soft tabs (2 spaces) for indentation
70-
* Prefer dashes over camelCasing in class names.
71-
- Underscores and PascalCasing are okay if you are using BEM (see [OOCSS and BEM](#oocss-and-bem) below).
72-
* Do not use ID selectors
73-
* When using multiple selectors in a rule declaration, give each selector its own line.
74-
* Put a space before the opening brace `{` in rule declarations
75-
* In properties, put a space after, but not before, the `:` character.
76-
* Put closing braces `}` of rule declarations on a new line
77-
* Put blank lines between rule declarations
69+
* Sử dụng soft tabs (2 dấu cách) cho khoảng cách thụt vào (indentation)
70+
* Nên sử dụng dấu gạch ngang trong camelCasing của tên class.
71+
- Dấu gạch dưới và PascalCasing sẽ không sao nếu bạn sử dụng BEM (xem [OOCSS and BEM](#oocss-and-bem) dưới đây).
72+
* Không sử dụng ID Selectors.
73+
* Khi sử dụng nhiều selector trong một khai báo, đặt mỗi selector trên một dòng kẻ.
74+
* Trước dấu ngoặc nhọn `{` phải có một dấu cách trong khai báo.
75+
* Trong thuộc tính, đặt một dấu cách đứng sau dấu hai chấm `:` .
76+
* Đặt dấu đóng ngoặc nhọn `}` của một khai báo trên một dòng kẻ mới.
77+
* Đặt một dòng kẻ trống giữa các khai báo.
7878

79-
**Bad**
79+
**Không tốt**
8080

8181
```css
8282
.avatar{
@@ -90,7 +90,7 @@ Finally, properties are what give the selected elements of a rule declaration th
9090
}
9191
```
9292

93-
**Good**
93+
**Tốt**
9494

9595
```css
9696
.avatar {
@@ -105,36 +105,36 @@ Finally, properties are what give the selected elements of a rule declaration th
105105
}
106106
```
107107

108-
### Comments
108+
### Chú thích
109109

110-
* Prefer line comments (`//` in Sass-land) to block comments.
111-
* Prefer comments on their own line. Avoid end-of-line comments.
112-
* Write detailed comments for code that isn't self-documenting:
113-
- Uses of z-index
114-
- Compatibility or browser-specific hacks
110+
* Nên dùng hai gạch (`//`) để đặt chú thích.
111+
* Nên đặt chú thích trên một dòng kẻ riêng, không đặt ở cuối dòng kẻ.
112+
* Viết chú thích chi tiết cho những dòng code mà không thể hiện được ý nghĩa rõ ràng khi đọc, ví dụ:
113+
- Sử dụng z-index
114+
- Khả năng tương thích và trình duyệt.
115115

116-
### OOCSS and BEM
116+
### OOCSS BEM
117117

118-
We encourage some combination of OOCSS and BEM for these reasons:
118+
Chúng tôi khuyến khích một số sự kết hợp giữa OOCSS BEM cho những lý do sau:
119119

120-
* It helps create clear, strict relationships between CSS and HTML
121-
* It helps us create reusable, composable components
122-
* It allows for less nesting and lower specificity
123-
* It helps in building scalable stylesheets
120+
* Nó giúp tạo ra mối quan hệ chặt chẽ rõ ràng giữa CSS HTML
121+
* Nó giúp tạo ra những thành phần có thể tái sử dụng.
122+
* Nó cho phép ít lồng nhau (nested) và giảm sự riêng biệt
123+
* Nó giúp xây dựng stylesheets có khả năng mở rộng
124124

125-
**OOCSS**, or “Object Oriented CSS”, is an approach for writing CSS that encourages you to think about your stylesheets as a collection of “objects”: reusable, repeatable snippets that can be used independently throughout a website.
125+
**OOCSS**, hay "CSS hướng đối tượng", là một phương pháp để viết code CSS mà khuyến khích bạn định hình stylesheets như một sự tập hợp của nhiều "đối tượng" (object): có thể tái sử dụng, có thể lặp lại độc lập xuyên suốt toàn bộ một trang web.
126126

127127
* Nicole Sullivan's [OOCSS wiki](https://github.com/stubbornella/oocss/wiki)
128-
* Smashing Magazine's [Introduction to OOCSS](http://www.smashingmagazine.com/2011/12/12/an-introduction-to-object-oriented-css-oocss/)
128+
* Smashing Magazine's [Giới thiệu về OOCSS](http://www.smashingmagazine.com/2011/12/12/an-introduction-to-object-oriented-css-oocss/)
129129

130-
**BEM**, or “Block-Element-Modifier”, is a _naming convention_ for classes in HTML and CSS. It was originally developed by Yandex with large codebases and scalability in mind, and can serve as a solid set of guidelines for implementing OOCSS.
130+
**BEM**, hay "Block-Element-Modifier", là một quy ước đặt tên cho classes trong HTML CSS. Ban đầu nó được phát triển bởi Yandex với codebases lớn, có khả năng mở rộng, và có thể coi như một tập hợp của các hướng dẫn cho việc thực hiện OOCSS.
131131

132132
* CSS Trick's [BEM 101](https://css-tricks.com/bem-101/)
133-
* Harry Roberts' [introduction to BEM](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/)
133+
* Harry Roberts' [Giới thiệt về BEM](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/)
134134

135-
We recommend a variant of BEM with PascalCased blocks”, which works particularly well when combined with components (e.g. React). Underscores and dashes are still used for modifiers and children.
135+
Chúng tôi khuyến nghị sử dụng một biến thể của BEM với PascalCased "blocks", mà làm việc riêng biệt khá hiệu quả với các thành phần (components) (e.g. React). Dấu gạch dưới và gạch ngang vẫn được sử dụng cho thành phần modifiers và thành phần con.
136136

137-
**Example**
137+
**Ví dụ**
138138

139139
```jsx
140140
// ListingCard.jsx
@@ -161,29 +161,29 @@ function ListingCard() {
161161
.ListingCard__content { }
162162
```
163163

164-
* `.ListingCard` is the “block” and represents the higher-level component
165-
* `.ListingCard__title` is an “element” and represents a descendant of `.ListingCard` that helps compose the block as a whole.
166-
* `.ListingCard--featured` is a “modifier” and represents a different state or variation on the `.ListingCard` block.
164+
* `.ListingCard` là một "block" và đại diện cho thành phần cao hơn
165+
* `.ListingCard__title` là một "phần tử" and biểu diễn như là một phần tử con của `.ListingCard` để tạo thành "block".
166+
* `.ListingCard--featured` là một "modifier" và đại diện cho các trạng thái khác nhau hay các biến thể của `.ListingCard` block.
167167

168-
### ID selectors
168+
### ID Selectors
169169

170-
While it is possible to select elements by ID in CSS, it should generally be considered an anti-pattern. ID selectors introduce an unnecessarily high level of [specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) to your rule declarations, and they are not reusable.
170+
Trong khi có thể chọn các phần tử theo ID trong CSS, nó vẫn không nên được sử dụng. ID selectors giới thiệu một sự riêng biệt [sự riêng biệt](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) không cần thiết cho các khai báo của bạn và không thể tái sử dụng lại được.
171171

172-
For more on this subject, read [CSS Wizardry's article](http://csswizardry.com/2014/07/hacks-for-dealing-with-specificity/) on dealing with specificity.
172+
Để biết thêm về chủ đề này, đọc [CSS Wizardry's article](http://csswizardry.com/2014/07/hacks-for-dealing-with-specificity/) on dealing with specificity.
173173

174174
### JavaScript hooks
175175

176-
Avoid binding to the same class in both your CSS and JavaScript. Conflating the two often leads to, at a minimum, time wasted during refactoring when a developer must cross-reference each class they are changing, and at its worst, developers being afraid to make changes for fear of breaking functionality.
176+
Tránh việc binding cùng một class trong CSS JavaScript. Việc làm đó có thể gây lãng phí thời gian ở mức nhẹ nhất khi lập trình viên phải kiểm tra chéo mỗi class khi thay đổi. Và trong trường hợp xấu nhất, lập trình viên có thể sẽ phải đối mặt với việc phá vỡ sự hoạt động của function.
177177

178-
We recommend creating JavaScript-specific classes to bind to, prefixed with `.js-`:
178+
Chúng tôi khuyến nghị tạo ra các class riêng cho JavaScript để bind, tiền tố bắt đầu với `.js-`:
179179

180180
```html
181181
<button class="btn btn-primary js-request-to-book">Request to Book</button>
182182
```
183183

184-
### Border
184+
### Đường viền
185185

186-
Use `0` instead of `none` to specify that a style has no border.
186+
Sử dụng `0` thay vì `none` để xác định rằng đối tượng này không có đường viền.
187187

188188
**Bad**
189189

@@ -203,16 +203,16 @@ Use `0` instead of `none` to specify that a style has no border.
203203

204204
## Sass
205205

206-
### Syntax
206+
### Cú pháp
207207

208-
* Use the `.scss` syntax, never the original `.sass` syntax
209-
* Order your regular CSS and `@include` declarations logically (see below)
208+
* Sử dụng `.scss` cú pháp, không bao giờ nên sử dụng cú pháp gốc của `.sass`
209+
* Sắp xếp CSS `@include` theo một logic (xem ở dưới)
210210

211-
### Ordering of property declarations
211+
### Sắp xếp các khai báo thuộc tính
212212

213-
1. Property declarations
213+
1. Khai báo thuộc tính
214214

215-
List all standard property declarations, anything that isn't an `@include` or a nested selector.
215+
Khai báo toàn bộ thuộc tính cơ bản trước, những gì không phải là `@include` hay khai báo lồng (nested) selector.
216216

217217
```scss
218218
.btn-green {
@@ -222,9 +222,9 @@ Use `0` instead of `none` to specify that a style has no border.
222222
}
223223
```
224224

225-
2. `@include` declarations
225+
2. Khai báo `@include`
226226

227-
Grouping `@include`s at the end makes it easier to read the entire selector.
227+
Nhóm `@include` ở cuối cùng để dễ dàng đọc toàn bộ selector.
228228

229229
```scss
230230
.btn-green {
@@ -235,9 +235,9 @@ Use `0` instead of `none` to specify that a style has no border.
235235
}
236236
```
237237

238-
3. Nested selectors
238+
3. Selectors lồng nhau
239239

240-
Nested selectors, _if necessary_, go last, and nothing goes after them. Add whitespace between your rule declarations and nested selectors, as well as between adjacent nested selectors. Apply the same guidelines as above to your nested selectors.
240+
Selectors lồng nhau, _nếu cần thiết_ , đặt ở cuối cùng, và không có gì viết sau nó nữa. Thêm khoảng trắng giữa khai báo và selector lồng nhau, cũng như giữa các phần tử con. Áp dụng toàn bộ hướng dẫn ở trên cho selector lồng nhau.
241241

242242
```scss
243243
.btn {
@@ -251,21 +251,21 @@ Use `0` instead of `none` to specify that a style has no border.
251251
}
252252
```
253253

254-
### Variables
254+
### Biến
255255

256-
Prefer dash-cased variable names (e.g. `$my-variable`) over camelCased or snake_cased variable names. It is acceptable to prefix variable names that are intended to be used only within the same file with an underscore (e.g. `$_my-variable`).
256+
Nên dùng gạch ngang giữa tên biến (e.g. `$my-variable`) thay vì camelCased or snake_cased. Nó cũng được phép dùng để đặt tiền tố cho tên biến nếu có ý định sử dụng trong cùng một file với dấu gạch dưới (e.g. `$_my-variable`).
257257

258258
### Mixins
259259

260-
Mixins should be used to DRY up your code, add clarity, or abstract complexity--in much the same way as well-named functions. Mixins that accept no arguments can be useful for this, but note that if you are not compressing your payload (e.g. gzip), this may contribute to unnecessary code duplication in the resulting styles.
260+
Mixins nên được sử dụng để không lặp lại các đoạn code giống nhau với phương châm (DRY - Don't-Repeat-Yourself) trong code của bạn, thêm sự rõ ràng, hoặc tách sự phức tạp - theo cách tương tự mà function được đặt tên. Mixins cho phép không có đối số có thể hữu ích cho việc này, nhưng chú ý rằng nếu bạn không nén lại (e.g. gzip), nó có thể đóng góp vào việc trùng lặp code không cần thiết.
261261

262262
### Extend directive
263263

264-
`@extend` should be avoided because it has unintuitive and potentially dangerous behavior, especially when used with nested selectors. Even extending top-level placeholder selectors can cause problems if the order of selectors ends up changing later (e.g. if they are in other files and the order the files are loaded shifts). Gzipping should handle most of the savings you would have gained by using `@extend`, and you can DRY up your stylesheets nicely with mixins.
264+
Nên tránh sử dụng `@extend` vì nó có một hành vi nguy hiểm tiềm tàng, đặc biệt khi sử dụng các selectors lồng nhau. Thậm chí mở rộng top-level placeholder selectors có thể gây ra vấn đề nếu thứ tự của selector kết thúc thay đổi sau đó (e.g. nếu họ đang ở một tệp tin khác, và thứ tự của các tệp tin được tải thay đổi.). Bạn có thể không lặp lại đoạn code của mình với mixins.
265265

266-
### Nested selectors
266+
### Selectors lồng nhau
267267

268-
**Do not nest selectors more than three levels deep!**
268+
**ĐỪNG selectors lồng hơn 3 cấp độ!**
269269

270270
```scss
271271
.page-container {
@@ -277,20 +277,20 @@ Mixins should be used to DRY up your code, add clarity, or abstract complexity--
277277
}
278278
```
279279

280-
When selectors become this long, you're likely writing CSS that is:
280+
Khi selectors trở nên như vậy, bạn có thể đã viết CSS theo:
281281

282-
* Strongly coupled to the HTML (fragile) *—OR—*
283-
* Overly specific (powerful) *—OR—*
284-
* Not reusable
282+
* Liên kết chặt với HTML (dễ đổ vỡ) *hoặc*
283+
* Quá cụ thể (powerful) *hoặc*
284+
* Không tái sử dụng
285285

286286

287-
Again: **never nest ID selectors!**
287+
Lặp lại: **không bao giờ được lồng ID selectors!**
288288

289-
If you must use an ID selector in the first place (and you should really try not to), they should never be nested. If you find yourself doing this, you need to revisit your markup, or figure out why such strong specificity is needed. If you are writing well formed HTML and CSS, you should **never** need to do this.
289+
Nếu bạn phải sử dụng ID selector ngay từ đầu (và bạn thực sự không nên làm thế), nó không bảo giờ nên được lồng nhau. Nếu bạn thấy mình làm điềuy, bạn cần phải xem xét lại code HTML, hoặc tìm hiểu tại sao lại cần cụ thể đến như vậy. Nếu bạn đang viết HTML CSS tốt, bạn **không bao giờ nên** cần phải làm điềuy.
290290

291-
## Translation
291+
## Dịch
292292

293-
This style guide is also available in other languages:
293+
Styleguide này cũng có sẵn trong các ngôn ngữ khác:
294294

295295
- ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese (Traditional)**: [ArvinH/css-style-guide](https://github.com/ArvinH/css-style-guide)
296296
- ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [Zhangjd/css-style-guide](https://github.com/Zhangjd/css-style-guide)

0 commit comments

Comments
 (0)