BASIC HTML & CSS
5. selector, units
[ 2017.01.19. Tue ]
To Do
1. Selector, Units
โ—‹ selector, px, %, em, rem
2. Box model, Display, Border, Background
โ—‹ box-sizing, display, margin, padding, shorthand
โ—‹ border, background
3. Text, Font, Web Font, Position, Float
โ—‹ font-family, font-size, font-weight, color, text-decoration, text-shadow
โ—‹ position, float, clear
4. Inheritance, Cascading, Effect
โ—‹ inherit, box-shadow, transition, transform, animation, keyframes
CSS์›น ๋ฌธ์„œ์˜ ๋””์ž์ธ ์š”์†Œ๋ฅผ ๋‹ด๋‹น
๊ฐ™์€ ๋งˆํฌ์—… ๋‹ค๋ฅธ ๋””์ž์ธ
http://csszengarden.com/
How to use?์–ด๋–ป๊ฒŒ ์›น ๋ฌธ์„œ์—์„œ CSS๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์„๊นŒ?
CSS ์‚ฌ์šฉ๋ฐฉ๋ฒ•
1. include css file
โ—‹ <link href="์™ธ๋ถ€ ์Šคํƒ€์ผ ํŒŒ์ผ ๊ฒฝ๋กœ" rel="stylesheet" type="text/css">
2. <style> in <head>
โ—‹ <head>
<style>
div { font-size: 20px; color: red; }
<style>
</head>
3. inline css
โ—‹ <div style="font-size: 20px; color: red;">
Syntax๋ฌธ๋ฒ•
CSS Syntax
p { color: red; }
selector valueproperty
Notationํ‘œ๊ธฐ๋ฒ•
CSS ํ‘œ๊ธฐ๋ฒ•
h1 { font-size: 20px; color: #fff; }
h1 {
font-size: 20px;
color: #fff;
}
h1
{
font-size: 20px;
color: #fff;
}
ํ‘œ๊ธฐ๋ฒ•์€
๋‹ค๋ฅด์ง€๋งŒ
๋ชจ๋‘ ๊ฐ™์€
์†Œ์Šค
์ž…๋‹ˆ๋‹ค.
/* ์ฃผ์„(Comment)
h1 {
font-size: 20px;
color: #fff;
}
*/
CSS ํ‘œ๊ธฐ๋ฒ•
h1 {
font-size: 20px;
color: #fff;
}
h1 {
font-size: 20px
color: #fff
}
h1
font-size: 20px
color: #fff
CSS SCSS SASS
CSS Preprocessor
Selector์„ ํƒ์ž
CSS Selector
1. ์ „์ฒด ์„ ํƒ์ž
2. ํƒœ๊ทธ ์„ ํƒ์ž
3. ์•„์ด๋”” ์„ ํƒ์ž
4. ํด๋ž˜์Šค ์„ ํƒ์ž
5. ํƒœ๊ทธ+์•„์ด๋”” ์„ ํƒ์ž
6. ํƒœ๊ทธ+ํด๋ž˜์Šค ์„ ํƒ์ž
7. ๊ทธ๋ฃน ์„ ํƒ์ž
8. ํ•˜์œ„ ์„ ํƒ์ž
9. ํ•˜์œ„ ์ง์† ๋ ˆ๋ฒจ ์„ ํƒ์ž
10. ๊ฐ™์€ ๋ ˆ๋ฒจ ์„ ํƒ์ž
11. ์ƒํƒœ ์„ ํƒ์ž
โ€ข *
โ€ข div
โ€ข #mmt
โ€ข .mmt
โ€ข div#mmt
โ€ข div.mmt
โ€ข div, span
โ€ข div span
โ€ข div > span
โ€ข div + span
โ€ข :focus, :hover
CSS Cheat Sheet Selector
id/class naming rule
1. ๊ฐ€
2. a1-_
3. 1
hong jisoo moonju seho hangyo
2 8 9 7, 4 1, 5, 6, 12
4. -a
5. -
6. --
10. _a
11. _1
12. __
7. -1
8. -_
9. _
์ •๋‹ต : 3, 5, 6, 7๋ฒˆ
3๋ฒˆ = '์ˆซ์ž'๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์—†์Œ
5๋ฒˆ = 'ํ•˜์ดํ”ˆ'์œผ๋กœ๋งŒ ๊ตฌ์„ฑํ•  ์ˆ˜ ์—†์Œ
6๋ฒˆ = 'ํ•˜์ดํ”ˆ+ํ•˜์ดํ”ˆ'์œผ๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์—†์Œ
ใ„ด ์œˆ๋„์šฐ ํฌ๋กฌ (o) ํŒŒ์ด์–ดํญ์Šค (o) / IE11 (x)
ใ„ด ๋งฅ ํฌ๋กฌ(o) / ์‚ฌํŒŒ๋ฆฌ-๋ฒ„์ „ 10.0.2(11602.3.12.0.1) (x)
7๋ฒˆ = 'ํ•˜์ดํ”ˆ+์ˆซ์ž'๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์—†์Œ
์ถœ์ฒ˜: http://zinee-world.tistory.com/438 [zineeworld]
id/class naming rule
CSS Priority
!important > inline style > #id > .class > tag
!important๋Š” ๋˜๋„๋ก ์“ฐ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. !important๊ฐ€ ์—‰ํ‚ค๊ธฐ ์‹œ์ž‘ํ•˜๋ฉด ์ง€์˜ฅ์ด ์—ด๋ ค์š”^^
Unit๋‹จ์œ„
CSS Units
https://developer.mozilla.org/en-US/docs/Web/CSS/length
em ex ch rem
vh vw vmin vmax
px mm q cm in pt pc %
Practice์˜ค๋Š˜์˜ ์—ฐ์Šต
https://flukeout.github.io/
easy to learn
Q&A
@hyejin
Facebook / Twitter / Codepen
@zineeworld

[Basic HTML/CSS] 5. css - selector, units

  • 1.
    BASIC HTML &CSS 5. selector, units [ 2017.01.19. Tue ]
  • 2.
    To Do 1. Selector,Units โ—‹ selector, px, %, em, rem 2. Box model, Display, Border, Background โ—‹ box-sizing, display, margin, padding, shorthand โ—‹ border, background 3. Text, Font, Web Font, Position, Float โ—‹ font-family, font-size, font-weight, color, text-decoration, text-shadow โ—‹ position, float, clear 4. Inheritance, Cascading, Effect โ—‹ inherit, box-shadow, transition, transform, animation, keyframes
  • 3.
    CSS์›น ๋ฌธ์„œ์˜ ๋””์ž์ธ์š”์†Œ๋ฅผ ๋‹ด๋‹น
  • 4.
    ๊ฐ™์€ ๋งˆํฌ์—… ๋‹ค๋ฅธ๋””์ž์ธ http://csszengarden.com/
  • 5.
    How to use?์–ด๋–ป๊ฒŒ์›น ๋ฌธ์„œ์—์„œ CSS๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์„๊นŒ?
  • 6.
    CSS ์‚ฌ์šฉ๋ฐฉ๋ฒ• 1. includecss file โ—‹ <link href="์™ธ๋ถ€ ์Šคํƒ€์ผ ํŒŒ์ผ ๊ฒฝ๋กœ" rel="stylesheet" type="text/css"> 2. <style> in <head> โ—‹ <head> <style> div { font-size: 20px; color: red; } <style> </head> 3. inline css โ—‹ <div style="font-size: 20px; color: red;">
  • 7.
  • 8.
    CSS Syntax p {color: red; } selector valueproperty
  • 9.
  • 10.
    CSS ํ‘œ๊ธฐ๋ฒ• h1 {font-size: 20px; color: #fff; } h1 { font-size: 20px; color: #fff; } h1 { font-size: 20px; color: #fff; } ํ‘œ๊ธฐ๋ฒ•์€ ๋‹ค๋ฅด์ง€๋งŒ ๋ชจ๋‘ ๊ฐ™์€ ์†Œ์Šค ์ž…๋‹ˆ๋‹ค. /* ์ฃผ์„(Comment) h1 { font-size: 20px; color: #fff; } */
  • 11.
    CSS ํ‘œ๊ธฐ๋ฒ• h1 { font-size:20px; color: #fff; } h1 { font-size: 20px color: #fff } h1 font-size: 20px color: #fff CSS SCSS SASS CSS Preprocessor
  • 12.
  • 13.
    CSS Selector 1. ์ „์ฒด์„ ํƒ์ž 2. ํƒœ๊ทธ ์„ ํƒ์ž 3. ์•„์ด๋”” ์„ ํƒ์ž 4. ํด๋ž˜์Šค ์„ ํƒ์ž 5. ํƒœ๊ทธ+์•„์ด๋”” ์„ ํƒ์ž 6. ํƒœ๊ทธ+ํด๋ž˜์Šค ์„ ํƒ์ž 7. ๊ทธ๋ฃน ์„ ํƒ์ž 8. ํ•˜์œ„ ์„ ํƒ์ž 9. ํ•˜์œ„ ์ง์† ๋ ˆ๋ฒจ ์„ ํƒ์ž 10. ๊ฐ™์€ ๋ ˆ๋ฒจ ์„ ํƒ์ž 11. ์ƒํƒœ ์„ ํƒ์ž โ€ข * โ€ข div โ€ข #mmt โ€ข .mmt โ€ข div#mmt โ€ข div.mmt โ€ข div, span โ€ข div span โ€ข div > span โ€ข div + span โ€ข :focus, :hover
  • 14.
  • 16.
    id/class naming rule 1.๊ฐ€ 2. a1-_ 3. 1 hong jisoo moonju seho hangyo 2 8 9 7, 4 1, 5, 6, 12 4. -a 5. - 6. -- 10. _a 11. _1 12. __ 7. -1 8. -_ 9. _
  • 17.
    ์ •๋‹ต : 3,5, 6, 7๋ฒˆ 3๋ฒˆ = '์ˆซ์ž'๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์—†์Œ 5๋ฒˆ = 'ํ•˜์ดํ”ˆ'์œผ๋กœ๋งŒ ๊ตฌ์„ฑํ•  ์ˆ˜ ์—†์Œ 6๋ฒˆ = 'ํ•˜์ดํ”ˆ+ํ•˜์ดํ”ˆ'์œผ๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์—†์Œ ใ„ด ์œˆ๋„์šฐ ํฌ๋กฌ (o) ํŒŒ์ด์–ดํญ์Šค (o) / IE11 (x) ใ„ด ๋งฅ ํฌ๋กฌ(o) / ์‚ฌํŒŒ๋ฆฌ-๋ฒ„์ „ 10.0.2(11602.3.12.0.1) (x) 7๋ฒˆ = 'ํ•˜์ดํ”ˆ+์ˆซ์ž'๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์—†์Œ ์ถœ์ฒ˜: http://zinee-world.tistory.com/438 [zineeworld] id/class naming rule
  • 18.
    CSS Priority !important >inline style > #id > .class > tag !important๋Š” ๋˜๋„๋ก ์“ฐ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. !important๊ฐ€ ์—‰ํ‚ค๊ธฐ ์‹œ์ž‘ํ•˜๋ฉด ์ง€์˜ฅ์ด ์—ด๋ ค์š”^^
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
    Facebook / Twitter/ Codepen @zineeworld