Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CSS Practices
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Ryan Chung
May 22, 2020
Technology
180
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CSS Practices
Ryan Chung
May 22, 2020
More Decks by Ryan Chung
See All by Ryan Chung
MovieBot Development
ryan403
0
340
Design Voice-First Games for Alexa
ryan403
0
93
AI Teaching Talk
ryan403
0
150
Cognitive Service
ryan403
0
120
jQuery & API Practices
ryan403
0
170
JavaScript Practices
ryan403
0
120
Web Programming - Lesson 6
ryan403
1
680
Web Programming - Lesson 7
ryan403
1
670
Web Programming - Lesson 5
ryan403
1
480
Other Decks in Technology
See All in Technology
JAWS-UG初心者支部#88わいわい初心塾(夏休みの宿題やったかGit編)
otsuki
0
130
Hub & Spoke 環境のネットワークルーティングを分解してみる
tsuyataku
1
530
【視聴者参加型!】AWSセキュリティアンチパターンクイズ
syoshie
0
410
DINO-EdgeQuery:Edge-First Polygon Decoding for Building Footprint Extraction from Satellite Imagery
lehupa
0
140
[RSJ26] AnoleVLA: Lightweight Vision-Language-Action Model with Deep State Space Models for Mobile Manipulation
keio_smilab
PRO
0
120
いかに伝えるか 〜新卒エンジニアの教育のための、ライトノベル活用の一例
ikedon
1
190
Beyond the Hype: Practical AI for Your Oracle Database with MCP
thatjeffsmith
1
260
Bet AI Day 2026丨How We Bet AI: AIとともに働く場をつくる
layerx
PRO
2
2.2k
AIエージェントの開発・提供におけるセキュリティリスクの論点と対策
flatt_security
1
570
生成AIのテナント制御とシャドーMCP対策 | AIを"止めずに"、情報を守る
yukun
0
110
プロダクトエンジニアに必要な「いい感じ」に作る能力 〜たくさん作れる時代に、どこまで作るかの決め方〜
jnishime_dresscode
2
1.4k
こんなアーキテクチャ図は嫌だ BEYOND THE TIME: 半年後の自分へ贈る15のメッセージ / 15 of Anti-pattern in AWS Architecture Diagrams
naospon
3
240
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Unsuck your backbone
ammeep
672
58k
sira's awesome portfolio website redesign presentation
elsirapls
0
400
Git: the NoSQL Database
bkeepers
PRO
432
67k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Embracing the Ebb and Flow
colly
88
5.2k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
400
Fireside Chat
paigeccino
42
4k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
300
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Chasing Engaging Ingredients in Design
codingconduct
0
300
Transcript
CSS – Cascading Style Sheets 階層式樣式表 補充教材
Box Model 箱子模型 ⚫ Margin –邊界 ⚫ Border – 邊框
⚫ Padding – 框距 ⚫ Content - 內容、文字/影像
⚫ margin-xxxx 分開標示 ⚫ margin-bottom ⚫ margin-left ⚫ margin-right ⚫
margin-top 邊界 Margin ⚫ margin 一次標示 ⚫ 10px − 上:10px、右:10px、下:10px、左:10px ⚫ 10px 5px − 上:10px、右:5px、下:10px、左:5px ⚫ 10px 5px 15px − 上:10px、右:5px、下:15px、左:5px ⚫ 10px 5px 15px 20px − 上:10px、右:5px、下:15px、左:20px
邊框 Border 1/2 ⚫ border-style 設定邊框樣式 (可每一邊不同) ⚫ 樣式 −
none, dotted, dashed, solid, double, groove 溝槽 − ridge 隆起, inset, outset, hidden ⚫ 四邊分開設 − border-top-style − border-right-style − border-bottom-style − border-left-style ⚫ 一次一起設 − border-style:dotted solid double dashed 上,右,下,左 − border-style:dotted solid double 上,左右,下 − border-style:dotted solid 上下,左右 − border-style:dotted 四邊相同
邊框 Border 2/2 ⚫ border-width 設定邊框寬度(框的粗細) ⚫ 四邊分開設 − border-top-width
− border-right-width − border-bottom-width − border-left-width ⚫ 一次一起設 − border-width:10px 5px 15px 20px 上,右,下,左 − border-width:10px 15px 5px 上,左右,下 − border-width:10px 5px 上下,左右 − border-width:10px 四邊相同 ⚫ border-color 顏色 ⚫ border 一次設定四邊的樣式、寬度與顏色 ⚫ border:5px solid red
框距 Padding ⚫ 設定內容與邊框的距離大小 ⚫ 各別設定 ⚫ padding-bottom ⚫ padding-left
⚫ padding-right ⚫ padding-top ⚫ 一次設定 ⚫ padding
練習:用CSS繪製 Box Model
練習:用CSS繪製 Box Model
對話泡泡
對話泡泡拆解 圓角邊框 顏色邊框 圓角邊框 背景顏色
用CSS產生三角形 每一邊先設定成不同的顏色
用CSS產生三角形 把div的大小縮成0px
用CSS產生三角形 其中一邊顏色保留,另外三邊設成透明色
index.html
index.html
style.css
CSS3 變形特效 – 旋轉 transform:rotate(30deg); 控制旋轉的度數
CSS3 動畫 @-webkit-keyframes name 定義動畫影格 name名稱 與 animation-name
對應 time可設定from、to或x% 決定每個時間點要呈現什麼效果 -webkit-animation 定義動畫屬性 animation-name:名稱,與keyframes對應 animation-duration:動畫播放時間長度(秒) animation-iteration-count:播放次數( n or infinite) animation-timing-function:ease、linear、ease-in、ease-out、ease-in-out animation-play-state:running、paused animation-delay:隔多久再開始
CSS3練習:旋轉 + 動畫 請讓車子的輪胎轉動
index.html
style.css
CSS Cascading & Inheritance 概念分析:層迭與繼承
Cascading • 相同的CSS屬性被賦予多次不同的屬性值,但卻套用在同一個元件時, 最後一個屬性值才會被使用。 • 表頭樣式與行內樣式衝突
Cascading • 相同的CSS屬性被賦予多次不同的屬性值,但卻套用在同一個元件時, 最後一個屬性值才會被使用。 • 表頭樣式前後衝突
Inheritance 繼承 • 有些CSS屬性會自動繼承給指定物件的子元件。 • 段落組件p下的粗體組件b
Inheritance 繼承 • 有些CSS屬性會自動繼承給指定物件的子元件。 • div --> p --> b
Inheritance 繼承 • 極少數CSS屬性繼承時會產生多重效果。 • div --> p --> b
Inheritance 繼承 • 有些CSS屬性會自動繼承給指定物件的子元件。 • 以比例方式設定會產生繼承值之後的比例
Inheritance 繼承 • 如果沒有自動繼承至子元件,可使用inherit強制繼承。 • 段落組件p下的粗體組件b
Inheritance 繼承 • 如果沒有自動繼承至子元件,可使用inherit強制繼承。 • 段落組件p下的粗體組件b
CSS規則套用的優先權 Specificity • 直接寫在HTML組件的style屬性 • 優先權值:1000 • CSS選擇器使用ID的方式 • 優先權值:100
• CSS選擇器使用class, pseudo-class或限定屬性 • 優先權值:10 • CSS選擇器使用HTML組件、偽組件(pseudo-element) • 優先權值:1
計算 Specificity • #container ul#menu li.active ul li:hover {} •
#container:100 • ul:1 • #menu:100 • li:1 • .active:10 • ul:1 • li:1 • :hover:10 Specificity:224 https://www.codecaptain.io/tools/css-specificity-calculator
聖旨駕到 !important • 淩駕所有優先權與位置
一個HTML元件可以套用多個類別 • rule1 + rule2
id 與 class 可以同時存在 • id的優先權值比較高
選擇器也可以巢狀使用 • 用空格隔開
選擇器也可一次指定多個 逗號隔開