CSS in the presentation layer
แนะนำใหม่ในบทเรียนนี้
| 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.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
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">?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
A tag style applies to every element of that type.
How is a comment written in CSS?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
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?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The inline style overrides the stylesheet.
Match each property to what it sets.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
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.
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้