Skip to content

Commit 6b3fa46

Browse files
committed
css语法
1 parent dfc7e67 commit 6b3fa46

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

original-docs/2015-04-03-css-syntax.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,44 @@ subtitle: "who{ what: how;}"
55
section: css
66
---
77

8-
The purpose of CSS is to define the layout _and_ styling of your HTML elements. The syntax is very simple:
8+
CSS的目的是定义HTML元素的布局和样式。 语法很简单:
99

1010
{% highlight css %}
11-
/* A CSS rule */
11+
/* CSS书写规则 */
1212
selector{ property: value;}
1313
{% endhighlight %}
1414

15-
You can read that as:
15+
你可以这样理解它:
1616

1717
{% highlight css %}
1818
who{ what: how;}
1919
{% endhighlight %}
2020

21-
CSS is a 3-part process:
21+
CSS的语法分为三部分:
2222

23-
* the **selector** defines _who_ is targeted, which HTML element(s)
24-
* the **property** defines _what_ charateristic to alter
25-
* the **value** defines _how_ to alter that charateristic
23+
* **选择器**定义目标HTML元素
24+
* **属性**定义要更改的特征
25+
* ****定义如何更改该特性
2626

27-
This whole block (selector/property/value) is a **CSS rule**.
27+
整个代码块(选择器/属性/值)是一个**CSS规范**
2828

29-
### Quick example
29+
### 快速举例
3030

31-
Let's say you want to change the color of all your **blockquotes**.
31+
假设你想改变所有**blockquote**元素的颜色
3232

3333
{% highlight html %}
3434
<blockquote>Something something</blockquote>
3535
{% endhighlight %}
3636

37-
Focus on the **tag name** (and forget about the angle brackets <> and the text). In our case, all that remains is _"blockquote"_. There's a direct relation between the tag name and the selector.
37+
关注**标签名**(往期尖括号<>和文本)。在这种情况下,剩下的就是_"blockquote"_。标签名和选择器之间有直接联系。
3838

39-
Let's use that in our CSS as a **selector**, and let's apply some styling:
39+
让我们在CSS中使用它作为选择器,并添加一些样式
4040

4141
{% highlight css %}
4242
blockquote{ background: lightgreen;}
4343
{% endhighlight %}
4444

45-
Interesting. But now, the text color doesn't really match the background color. Let's improve that:
45+
有趣的是。现在,文字颜色与背景颜色不一致。 让我们改进一下:
4646

4747
{% highlight css %}
4848
blockquote{
@@ -51,12 +51,12 @@ blockquote{
5151
}
5252
{% endhighlight %}
5353

54-
So 2 things happened:
54+
所以发生了两件事情:
5555

56-
* we added a _second_ property/value pair, while keeping only _one_ selector: you can set as many properties as you want for any set of selectors
57-
* we put each property/value pair on its _own line_: like in HTML, the **whitespace** isn't important. It's the special characters `{}` `:` and `;` that matter. As a result, you can format your CSS as you wish, to make it more readable, as long as its syntax remains valid.
56+
* 我们添加了_第二个_键值对,同时只保留_一个_选择器:你可以为任何选择器设定任意数量的属性。
57+
* 我们可以把每个键值对放在_一行_:就像HTML一样。**空格键**并不重要。特殊符号`{}` `:` `;` 很重要。因此,您可以根据需要格式化CSS,使其更易于阅读,只要其语法仍然有效。
5858

59-
The `<blockquote>` HTML tag is a **block** element. It has an **inline** counterpart: `<q>`. As they both serve the same purpose (but in different contexts), we'd like to style them identically. We could copy-paste the CSS rule and just change the selector, but there is as you would have guessed, a quicker way:
59+
`<blockquote>`标签是一个**块级**元素。它有个**行内**元素与其对应。他们都服务于相同的目的(但他们在不同的上下文中),我们希望对他使用相同的样式。我们可以复制粘贴CSS代码,并只改变选择器。但是你可能会用到,一个更快速的方式。
6060

6161
{% highlight css %}
6262
q,
@@ -66,24 +66,24 @@ blockquote{
6666
}
6767
{% endhighlight %}
6868

69-
Now we have 2 selectors and 2 properties. We consequently have a _set_ of selectors and a _set_ of properties (with their respective values).
69+
现在我们有两个选择器和两个属性。因此,我们有一组选择器和一组属性(具有各自的值)。
7070

71-
We can have multiple selectors, multiple properties, and sometimes (but rarely) multiple values.
71+
我们可以有多个选择器,多个属性,有时(但很少)会有多个值。
7272
{: .info}
7373

74-
### Comments
74+
### 注释
7575

76-
As in HTML, it can be handy to write CSS comments:
76+
就像在HTML中一样,可以方便地编写CSS注释:
7777

7878
{% highlight css %}
79-
/* This is a CSS comment */
79+
/* 这是CSS代码注释 */
8080
q,
8181
blockquote{
8282
background: lightgreen;
8383
color: darkgreen;
8484
}
8585
/*
86-
Comments are only meant to be read by humans
87-
and won't be parsed by the computer
86+
注释仅供人阅读
87+
并不会被计算机解析
8888
*/
8989
{% endhighlight %}

0 commit comments

Comments
 (0)