CSS in the presentation layer
Đã giới thiệuTrong bài học này
| English |
|---|
| inline style |
| class/klæs/ |
| cascade/kəˈskeɪd/ |
| property/ˈprɒpəti/ |
One file styles the site
- CSS builds the presentation layer. A shared stylesheet keeps every page in the same house style.
Stylesheets and inline styles 行内样式
h1 { color: navy; font-size: 28px; text-align: center; }
.highlight { background-color: yellow; font-weight: bold; }
- External stylesheet: a .css file attached to pages. Inline style:
<p style="color: red;">. - Comments:
/* … */.
Match each term to its meaning.
Độ khó 2/5 · 140 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Two places for styles.
Tag styles and classes 类
- A tag style (
h1 {…}) applies to every element of that type. - A class (
.highlight {…}) applies only where used:<p class="highlight">, on any kind of element.
Which applies only where it is used, such as <p class="highlight">?
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
A tag style applies to every element of that type.
How is a comment written in CSS?
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
HTML uses .
The cascade 层叠
- An inline style overrides attached stylesheets.
- Equally specific rules: the stylesheet attached last wins. Attach with relative paths.
Stylesheet p { color: black; }; one tag <p style="color: red;">: that paragraph is red.
The stylesheet sets p { color: black; }; one tag is <p style="color: red;">. What colour is that paragraph?
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
The inline style overrides the stylesheet.
Match each property to what it sets.
Độ khó 2/5 · 140 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Each property controls one feature.
Properties
| for | properties |
|---|---|
| background | background-color, background-image |
| font | font-family, font-size, color, text-align, font-weight |
| table | width, padding, border, border-collapse, vertical-align |
End each declaration with a semicolon. A missing ; can stop the next property 属性 working.
External stylesheets style many pages; inline styles one tag. Tag styles apply everywhere; classes only where used. In the cascade, inline beats attached, and the last attached sheet wins ties.
Đã xảy ra vấn đề gì? Chỉ đội ngũ trang web nhìn thấy thông tin này.