html&css 4 - intermediate css (1/2)

100

Click here to load reader

Upload: dinis-correia

Post on 03-Nov-2014

95 views

Category:

Technology


16 download

DESCRIPTION

Slides for my in-house HTML & CSS trainning at SAPO. Intermediate CSS: the cascade, inheritance and text styling.

TRANSCRIPT

Page 1: HTML&CSS 4 - Intermediate CSS (1/2)

&DINIS CORREIA 2011

cbn

4HTMLCSS

Page 2: HTML&CSS 4 - Intermediate CSS (1/2)

CSS HTML + CSS1CASCADE E

INHERITANCE2ESTILIZAR

TEXTO3⇪

Page 3: HTML&CSS 4 - Intermediate CSS (1/2)

CSS

ESTILIZAR TEXTO3

na sessão anterior...

Page 4: HTML&CSS 4 - Intermediate CSS (1/2)

HTML + CSS

Page 5: HTML&CSS 4 - Intermediate CSS (1/2)

1. Inline

2. Embed

3. External

HTML + CSS

Page 6: HTML&CSS 4 - Intermediate CSS (1/2)

1. Inline

2. Embed

3. External

HTML + CSS

Page 7: HTML&CSS 4 - Intermediate CSS (1/2)

<p  style="color:  blue;">Lorem  ipsum  dolor.</p>

Page 8: HTML&CSS 4 - Intermediate CSS (1/2)

1. Inline

2. Embed

3. External

HTML + CSS

Page 9: HTML&CSS 4 - Intermediate CSS (1/2)

<head><title>Um  título</title>

<meta  name="description"  content="A  descrição  da  página"><meta  name="keywords"  content="vídeos,fotos,pesquisa">

<style>p  {

color:  blue;}

</style></head>

Page 10: HTML&CSS 4 - Intermediate CSS (1/2)

1. Inline

2. Embed

3. External

HTML + CSS

Page 11: HTML&CSS 4 - Intermediate CSS (1/2)

<head><title>Um  título</title>

<meta  name="description"  content="A  descrição  da  página"><meta  name="keywords"  content="vídeos,fotos,pesquisa">

<link  type="text/css"  rel="stylesheet"  media="screen"  href="style.css"></head>

Page 12: HTML&CSS 4 - Intermediate CSS (1/2)

CASCADE & INHERITANCE

Page 13: HTML&CSS 4 - Intermediate CSS (1/2)
Page 14: HTML&CSS 4 - Intermediate CSS (1/2)

User agent User Author

Page 15: HTML&CSS 4 - Intermediate CSS (1/2)
Page 16: HTML&CSS 4 - Intermediate CSS (1/2)

User agent User Author

Page 17: HTML&CSS 4 - Intermediate CSS (1/2)

INHERITANCE

Page 18: HTML&CSS 4 - Intermediate CSS (1/2)
Page 19: HTML&CSS 4 - Intermediate CSS (1/2)
Page 20: HTML&CSS 4 - Intermediate CSS (1/2)

HERDAM NÃO HERDAMcolor background

font border

letter-spacing display

line-height float/clear

list-style height/width

text-align margin

text-indent outline

text-transform overflow

white-space padding

word-spacing position

... ...

Page 21: HTML&CSS 4 - Intermediate CSS (1/2)
Page 22: HTML&CSS 4 - Intermediate CSS (1/2)

body  {  font-­‐family:  Arial;  }

CSS

Page 23: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  border:  inherit;  }

CSS

Page 24: HTML&CSS 4 - Intermediate CSS (1/2)

CASCADE

Page 25: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  color:  blue;  }

p  {  color:  red;  }

CSS

Page 26: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  color:  blue;  }

p  {  color:  red;  }

CSS

Page 27: HTML&CSS 4 - Intermediate CSS (1/2)

1. Origem

2. Especificidade

3. Ordem

CONFLITOSresolvidos  por

Page 28: HTML&CSS 4 - Intermediate CSS (1/2)

1. Origem

2. Especificidade

3. Ordem

CONFLITOSresolvidos  por

Page 29: HTML&CSS 4 - Intermediate CSS (1/2)

User agent User Author

21 3

Page 30: HTML&CSS 4 - Intermediate CSS (1/2)

User agent User Author

21 3

User!important

54

Author!important

Page 31: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  color:  blue;  }

p  {  color:  red  !important;  }

CSS

Page 32: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

p  {  color:  blue;  }

Page 33: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

p  {  color:  blue;  }

p  {  color:  yellow;  }

Page 34: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

p  {  color:  blue;  }

p  {  color:  yellow;  }

p  {  color:  green;  }

Page 35: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

p  {  color:  blue;  }

p  {  color:  yellow;  }

p  {  color:  green;  }p  {  color:  blue  !important;  }

Page 36: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

p  {  color:  blue;  }

p  {  color:  yellow;  }p  {  color:  black  !important;  }

p  {  color:  green;  }p  {  color:  blue  !important;  }

Page 37: HTML&CSS 4 - Intermediate CSS (1/2)

1. Origem

2. Especificidade

3. Ordem

CONFLITOSresolvidos  por

Page 38: HTML&CSS 4 - Intermediate CSS (1/2)

1. Origem

2. Especificidade

3. Ordem

CONFLITOSresolvidos  por

Page 39: HTML&CSS 4 - Intermediate CSS (1/2)

PONTUAÇÕES PARA CSSFOTO DE MICHAEL PICK c HTTP://FLIC.KR/P/6ZXG7A

Page 40: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  color:  blue;  }

#container  .nav  p  {  color:  red;  }

Page 41: HTML&CSS 4 - Intermediate CSS (1/2)

0Inline ClassID Elements

000

Page 42: HTML&CSS 4 - Intermediate CSS (1/2)

<p  style="color:  red;">Um  parágrafo.</p>

CSS

0Inline ClassID Elements

001

Page 43: HTML&CSS 4 - Intermediate CSS (1/2)

#container  {  color:  red;  }

CSS

0Inline ClassID Elements

010

Page 44: HTML&CSS 4 - Intermediate CSS (1/2)

.nav  {  color:  red;  }

CSS

0Inline ClassID Elements

100

Page 45: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  color:  red;  }

CSS

1Inline ClassID Elements

000

Page 46: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  color:  blue;  }

.lead  {  color:  red;  }

CSS

Page 47: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  color:  blue;  }

.lead  {  color:  red;  }

CSS

Page 48: HTML&CSS 4 - Intermediate CSS (1/2)

#container  .content  p  {  color:  red;  }

CSS

1Inline ClassID Elements

110

Page 49: HTML&CSS 4 - Intermediate CSS (1/2)

#container  .content  p:first-­‐line  {  color:  red;  }

CSS

1Inline ClassID Elements

210

Page 50: HTML&CSS 4 - Intermediate CSS (1/2)

#container  .content  p  strong  {  color:  red;  }

CSS

2Inline ClassID Elements

110

Page 51: HTML&CSS 4 - Intermediate CSS (1/2)

1. Origem

2. Especificidade

3. Ordem

CONFLITOSresolvidos  por

Page 52: HTML&CSS 4 - Intermediate CSS (1/2)

1. Origem

2. Especificidade

3. Ordem

CONFLITOSresolvidos  por

Page 53: HTML&CSS 4 - Intermediate CSS (1/2)

.content  p  {  color:  blue;  }

.content  p  {  color:  red;  }

CSS

Page 54: HTML&CSS 4 - Intermediate CSS (1/2)

.content  p  {  color:  blue;  }

.content  p  {  color:  red;  }

CSS

Page 55: HTML&CSS 4 - Intermediate CSS (1/2)
Page 56: HTML&CSS 4 - Intermediate CSS (1/2)

EXERCÍCIOFOTO DE SOCIALISBETTER c HTTP://FLIC.KR/P/5BMFB7

Page 57: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

h2  {  color:  blue;  }

h2  {  color:  yellow;  }

Page 58: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

h2  {  color:  blue;  }

h2  {  color:  yellow;  }

Page 59: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

h2  {  color:  blue;  }

h2  {  color:  yellow;  }

h2  {  color:  red;  }

Page 60: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

h2  {  color:  blue;  }

h2  {  color:  yellow;  }

h2  {  color:  red;  }

Page 61: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

h2  {  color:  blue;  }

h2  {  color:  yellow;  }

h2  {  color:  red;  }

<h2  style="color:  black;">Título</h2>

Page 62: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

h2  {  color:  blue;  }

h2  {  color:  yellow;  }

h2  {  color:  red;  }

<h2  style="color:  black;">Título</h2>

Page 63: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

h2  {  color:  blue;  }

h2  {  color:  yellow;  }h2  {  color:  green  !important;  }

<h2  style="color:  black;">Título</h2>

Page 64: HTML&CSS 4 - Intermediate CSS (1/2)

User agent

User

Author

h2  {  color:  blue;  }

h2  {  color:  yellow;  }h2  {  color:  green  !important;  }

<h2  style="color:  black;">Título</h2>

Page 65: HTML&CSS 4 - Intermediate CSS (1/2)

p.lead  {  color:  blue;  }

CSS

p  {  color:  red;  }

Page 66: HTML&CSS 4 - Intermediate CSS (1/2)

p.lead  {  color:  blue;  }

CSS

p  {  color:  red;  }

Page 67: HTML&CSS 4 - Intermediate CSS (1/2)

p.lead  {  color:  blue;  }

CSS

p  {  color:  red;  }

p.lead  {  color:  black;  }

Page 68: HTML&CSS 4 - Intermediate CSS (1/2)

p.lead  {  color:  blue;  }

CSS

p  {  color:  red;  }

p.lead  {  color:  black;  }

Page 69: HTML&CSS 4 - Intermediate CSS (1/2)

p.lead  {  color:  blue;  }

CSS

p  {  color:  red;  }

p.lead  {  color:  black;  }

#container  p  {  color:  white;  }

Page 70: HTML&CSS 4 - Intermediate CSS (1/2)

p.lead  {  color:  blue;  }

CSS

p  {  color:  red;  }

p.lead  {  color:  black;  }

#container  p  {  color:  white;  }

Page 71: HTML&CSS 4 - Intermediate CSS (1/2)

ESTILIZAR TEXTO

Page 72: HTML&CSS 4 - Intermediate CSS (1/2)

ESTILIZAR TEXTOfont-­‐size

Page 73: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  font-­‐size:  12px;  }

CSS

Page 74: HTML&CSS 4 - Intermediate CSS (1/2)

px

em

%

keywords

Page 75: HTML&CSS 4 - Intermediate CSS (1/2)

px

em%

keywords

ABSOLUTAS

RELATIVAS

Page 76: HTML&CSS 4 - Intermediate CSS (1/2)
Page 77: HTML&CSS 4 - Intermediate CSS (1/2)

px

em%

keywords

ABSOLUTAS

RELATIVAS

Page 78: HTML&CSS 4 - Intermediate CSS (1/2)

px

em%

keywords

ABSOLUTAS

RELATIVAS

font-­‐size:  12px;

font-­‐size:  1.3em;

font-­‐size:  80%;

font-­‐size:  small;

Page 79: HTML&CSS 4 - Intermediate CSS (1/2)

body  {  font-­‐size:  16px;  }

CSS

p  {  font-­‐size:  0.86em  }

14px / 16px = 0.86

Page 80: HTML&CSS 4 - Intermediate CSS (1/2)

body  {  font-­‐size:  62,5%;  }

CSS

p  {  font-­‐size:  1.2em  }

10px x 1.2em = 12px

Page 81: HTML&CSS 4 - Intermediate CSS (1/2)

ESTILIZAR TEXTO

font-­‐family

Page 82: HTML&CSS 4 - Intermediate CSS (1/2)

body  {  font-­‐family:  Helvetica,  Arial,  sans-­‐serif;  }

CSS

Page 83: HTML&CSS 4 - Intermediate CSS (1/2)

body  {  font-­‐family:  "Times  New  Roman",  serif;  }

CSS

Page 84: HTML&CSS 4 - Intermediate CSS (1/2)

Exemplo serif

Exemplo sans-serif

Exemplo monospace

Exemplo cursive

Exemplo fantasy

Page 85: HTML&CSS 4 - Intermediate CSS (1/2)

SerifSans-serif

Page 86: HTML&CSS 4 - Intermediate CSS (1/2)

ESTILIZAR TEXTO

font-­‐stylefont-­‐weightfont-­‐variant

Page 87: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  font-­‐style:  italic;  }  

p  {  font-­‐style:  oblique;  }  

p  {  font-­‐style:  normal;  }  

CSS

Page 88: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  font-­‐variant:  small-­‐caps;  }  

p  {  font-­‐variant:  normal;  }  

CSS

Page 89: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  font-­‐weight:  normal;  }  

p  {  font-­‐weight:  bold;  }  

p  {  font-­‐weight:  400;  }

CSS

Page 90: HTML&CSS 4 - Intermediate CSS (1/2)

ESTILIZAR TEXTOshorthand

Page 91: HTML&CSS 4 - Intermediate CSS (1/2)

body  {  font:  italic  normal  bold  12px  Helvetica,  Arial,  sans-­‐serif  }

CSS

Page 92: HTML&CSS 4 - Intermediate CSS (1/2)

body  {  font:  italic  normal  bold  12px  Helvetica,  Arial,  sans-­‐serif  }

CSS

-style

-variant

-weight

-size

-family

Page 93: HTML&CSS 4 - Intermediate CSS (1/2)

ESTILIZAR TEXTO

outras  propriedades

Page 94: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  text-­‐align:  right;  }  

p  {  text-­‐align:  left;  }

p  {  text-­‐align:  center;  }

p  {  text-­‐align:  justify;  }  

CSS

Page 95: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  letter-­‐spacing:  0.05em;  }  

p  {  word-­‐spacing:  0.3em;  }

CSS

Page 96: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  text-­‐indent:  10px;  }  

CSS

Page 97: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  text-­‐indent:  1.5em;  }  

CSS

Page 98: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  text-­‐transform:  uppercase;  }  

p  {  text-­‐transform:  lowercase;  }

p  {  text-­‐transform:  none;  }  

CSS

Page 99: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  text-­‐decoration:  underline;  }  

p  {  text-­‐decoration:  line-­‐through;  }

p  {  text-­‐decoration:  none;  }  

CSS

Page 100: HTML&CSS 4 - Intermediate CSS (1/2)

p  {  line-­‐height:  16px;  }  

p  {  line-­‐height:  1em;  }

p  {  line-­‐height:  1.5;  }  

CSS