SlideShare uma empresa Scribd logo
1 de 39
Baixar para ler offline
ESTILOS AVANÇADOS
Estilos Avançados
• Alguns tipos de estilos não foram discutidos
– Estilos associados a ações dos elementos
– Estilos associados a ordem dos elementos
– Estilos de posicionamento
• Iremos estudá-los nesta aula
Pseudo-Classes
• Definir estilos para estados dos elementos
• Como definir estilo de elemento em foco?
• E o estilo de elemento sob o mouse?
• seletor:estado {
propriedade: valor;
}
Pseudo-Classes
• Pseudo-Classes mais comuns
– :link Links não visitados
– :visited Links já visitados
– :hover Mouse sobre o elemento
– :active Elemento ativo (botão pressionado)
– :focus Elemento com foco ativo
Pseudo-Classes
• Exemplos de Pseudo-Classes
a:link {
color: green;
text-decoration: none;
}
a:hover {
color: red;
text-decoration: underline;
}
Pseudo-Classes
• Exemplos de Pseudo-Classes
input:focus {
background-color: yellow;
}
#menu:hover {
background-color: blue;
}
Pseudo-Elementos
• Definir estilos para elementos que aparecem
em determinada ordem (posição)
• E se eu quiser definir um estilo para o
primeiro elemento de uma lista?
• Ou definir algo diferente para o último?
• seletor:descritor {
propriedade: valor;
}
Pseudo-Elementos
• Pseudo-Elementos mais comuns
– :first-child Primeiro elemento
– :last-child Último elemento
– :first-letter Primeira letra
– :first-line Primeira linha
– :nth-child(regra) “Enésimo” elemento
Pseudo-Elementos
• Exemplos
p:first-letter {
font-size: 1.2em;
}
p:first-line {
font-variant: small-caps;
}
li.menu:last-child {
border-right: none;
}
Pseudo-Elementos
• Exemplos
tr:nth-child(2n+1) td {
background-color: white;
}
(A partir da posição 1, de dois em dois)
tr:nth-child(3n+2) td {
background-color: gray;
}
(A partir da posição 2, de três em três)
POSICIONAMENTO COM
O CSS: MOTIVAÇÃO
Exemplo de Mudança de Layout
Exemplo de Mudança de Layout
Layout Base: Tutorial Básico
MENU
TÍTULO
SEÇÃO 1
Layout Base: Tutorial Básico
MENU
TÍTULO
SEÇÃO 1
Layout Base: Tutorial Básico
• Construa com o professor para
compreender o processo...
POSICIONAMENTO COM
O CSS: TIPOS DE
POSICIONAMENTO
Posicionamento + CSS: position
• Atributo position: static
• Ref.: outros elementos
• Posicionamento padrão
– Elementos pequenos
• Lado a lado
– Elementos “grandes”
• Um em baixo do outro
img img img
p
li
p
Posicionamento + CSS: position
• Atributo position: static
• Espaçamento
– margin
• Centralizar
– margin-left: auto;
– margin-right: auto;
• Tamanho
– Conteúdo, padding,
border, width, height
img img img
p
li
p
Posicionamento + CSS: position
• Atributo position: absolute
• Ref.: janela (navegador)
– Rola com documento
• Espaçamento
– margin, left, right, top
bottom
• Tamanho
– Conteúdo, padding,
border, width, height
p
li
p
img
Posicionamento + CSS: position
• Atributo position: relative
• Elemento relativo...
– Posiciona-se como static
• Para que serve?
– Muda comportamento
dos absolutes internos!
img img img
p
li
p
Posicionamento + CSS: position
• position: absolute (dentro de relative)
• Ref.: elemento relativo
• Muda a referência!
– margin, left, right, top
bottom
<div id=“d1”></div>
<div id=“d2”>
<div id=“d3”>
</div>
div #d1
div #d2 relative
div
#d3
#d3 absolute com
top=0px e right=0px
Posicionamento + CSS: position
• position: absolute – top 0x; right: 0px
– Dentro de relative x Dentro de static
div
div relative
div
div absolute com top=0px
e right=0px
div
div static
div
div
div absolute com top=0px
e right=0px
Posicionamento + CSS: position
• Atributo position: fixed
• Ref.: janela (navegador)
– Não rola c/ documento
• Espaçamento
– margin, left, right, top
bottom
• Tamanho
– Conteúdo, padding,
border, width, height
img img img
p
p
img
li
Posicionamento + CSS: position
• Atributo position: fixed
• Ref.: janela (navegador)
– Não rola c/ documento
• Espaçamento
– margin, left, right, top
bottom
• Tamanho
– Conteúdo, padding,
border, width, height
img img img
p
p
img
li
Posicionamento + CSS: position
• Atributo position: fixed
• Ref.: janela (navegador)
– Não rola c/ documento
• Espaçamento
– margin, left, right, top
bottom
• Tamanho
– Conteúdo, padding,
border, width, height
img img img
p
p
img
li
Posicionamento + CSS: position
• Atributo position: fixed
• Ref.: janela (navegador)
– Não rola c/ documento
• Espaçamento
– margin, left, right, top
bottom
• Tamanho
– Conteúdo, padding,
border, width, height
img img img
p
p
img
li
Posicionamento + CSS: position
• Atributo position: fixed
• Ref.: janela (navegador)
– Não rola c/ documento
• Espaçamento
– margin, left, right, top
bottom
• Tamanho
– Conteúdo, padding,
border, width, height
img img img
p
p
img
li
POSICIONAMENTO COM
O CSS: ELEMENTOS
“PRESOS” ÀS LATERAIS
Posicionamento + CSS: float
• Atributo float: none
• Seguida a regra normal
do posicionamento img
p
p
p
Posicionamento + CSS: float
• Atributo float: left
• Elmento “gruda” na
lateral... E os outros
elementos “escorrem”
à sua volta
p
p
p
img
Posicionamento + CSS: float
• Atributo float: right
• Elmento “gruda” na
lateral... E os outros
elementos “escorrem”
à sua volta
p
p
p
img
POSICIONAMENTO COM O
CSS: MODIFICANDO A
FORMA DE APRESENTAÇÃO
Posicionamento + CSS: display
• Sem atributo display: block
• Apresenta elemento
como previsto
• Listas, por exemplo
ul
li
li
li
li
Posicionamento + CSS: display
• Sem atributo display: inline / inline-block
• Apresenta elementos
em linha
• Por exemplo, listas
ul
li li li li
Posicionamento + CSS: display
• Sem atributo display: none
• Some com elementos ul
li li li li
POSICIONAMENTO NA
PRÁTICA: TUTORIAL
Entendendo o posicionamento...
• Acompanhe o professor com o código “pos”
para entender o mecanismo...
CONCLUSÕES

Mais conteúdo relacionado

Último

Assessement Boas Praticas em Kubernetes.pdf
Assessement Boas Praticas em Kubernetes.pdfAssessement Boas Praticas em Kubernetes.pdf
Assessement Boas Praticas em Kubernetes.pdf
Natalia Granato
 

Último (6)

Boas práticas de programação com Object Calisthenics
Boas práticas de programação com Object CalisthenicsBoas práticas de programação com Object Calisthenics
Boas práticas de programação com Object Calisthenics
 
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docxATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
 
Padrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemploPadrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemplo
 
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docxATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
 
Assessement Boas Praticas em Kubernetes.pdf
Assessement Boas Praticas em Kubernetes.pdfAssessement Boas Praticas em Kubernetes.pdf
Assessement Boas Praticas em Kubernetes.pdf
 
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docxATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
 

Destaque

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destaque (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

AULA05 - folhas de estilo

  • 2. Estilos Avançados • Alguns tipos de estilos não foram discutidos – Estilos associados a ações dos elementos – Estilos associados a ordem dos elementos – Estilos de posicionamento • Iremos estudá-los nesta aula
  • 3. Pseudo-Classes • Definir estilos para estados dos elementos • Como definir estilo de elemento em foco? • E o estilo de elemento sob o mouse? • seletor:estado { propriedade: valor; }
  • 4. Pseudo-Classes • Pseudo-Classes mais comuns – :link Links não visitados – :visited Links já visitados – :hover Mouse sobre o elemento – :active Elemento ativo (botão pressionado) – :focus Elemento com foco ativo
  • 5. Pseudo-Classes • Exemplos de Pseudo-Classes a:link { color: green; text-decoration: none; } a:hover { color: red; text-decoration: underline; }
  • 6. Pseudo-Classes • Exemplos de Pseudo-Classes input:focus { background-color: yellow; } #menu:hover { background-color: blue; }
  • 7. Pseudo-Elementos • Definir estilos para elementos que aparecem em determinada ordem (posição) • E se eu quiser definir um estilo para o primeiro elemento de uma lista? • Ou definir algo diferente para o último? • seletor:descritor { propriedade: valor; }
  • 8. Pseudo-Elementos • Pseudo-Elementos mais comuns – :first-child Primeiro elemento – :last-child Último elemento – :first-letter Primeira letra – :first-line Primeira linha – :nth-child(regra) “Enésimo” elemento
  • 9. Pseudo-Elementos • Exemplos p:first-letter { font-size: 1.2em; } p:first-line { font-variant: small-caps; } li.menu:last-child { border-right: none; }
  • 10. Pseudo-Elementos • Exemplos tr:nth-child(2n+1) td { background-color: white; } (A partir da posição 1, de dois em dois) tr:nth-child(3n+2) td { background-color: gray; } (A partir da posição 2, de três em três)
  • 12. Exemplo de Mudança de Layout
  • 13. Exemplo de Mudança de Layout
  • 14. Layout Base: Tutorial Básico MENU TÍTULO SEÇÃO 1
  • 15. Layout Base: Tutorial Básico MENU TÍTULO SEÇÃO 1
  • 16. Layout Base: Tutorial Básico • Construa com o professor para compreender o processo...
  • 17. POSICIONAMENTO COM O CSS: TIPOS DE POSICIONAMENTO
  • 18. Posicionamento + CSS: position • Atributo position: static • Ref.: outros elementos • Posicionamento padrão – Elementos pequenos • Lado a lado – Elementos “grandes” • Um em baixo do outro img img img p li p
  • 19. Posicionamento + CSS: position • Atributo position: static • Espaçamento – margin • Centralizar – margin-left: auto; – margin-right: auto; • Tamanho – Conteúdo, padding, border, width, height img img img p li p
  • 20. Posicionamento + CSS: position • Atributo position: absolute • Ref.: janela (navegador) – Rola com documento • Espaçamento – margin, left, right, top bottom • Tamanho – Conteúdo, padding, border, width, height p li p img
  • 21. Posicionamento + CSS: position • Atributo position: relative • Elemento relativo... – Posiciona-se como static • Para que serve? – Muda comportamento dos absolutes internos! img img img p li p
  • 22. Posicionamento + CSS: position • position: absolute (dentro de relative) • Ref.: elemento relativo • Muda a referência! – margin, left, right, top bottom <div id=“d1”></div> <div id=“d2”> <div id=“d3”> </div> div #d1 div #d2 relative div #d3 #d3 absolute com top=0px e right=0px
  • 23. Posicionamento + CSS: position • position: absolute – top 0x; right: 0px – Dentro de relative x Dentro de static div div relative div div absolute com top=0px e right=0px div div static div div div absolute com top=0px e right=0px
  • 24. Posicionamento + CSS: position • Atributo position: fixed • Ref.: janela (navegador) – Não rola c/ documento • Espaçamento – margin, left, right, top bottom • Tamanho – Conteúdo, padding, border, width, height img img img p p img li
  • 25. Posicionamento + CSS: position • Atributo position: fixed • Ref.: janela (navegador) – Não rola c/ documento • Espaçamento – margin, left, right, top bottom • Tamanho – Conteúdo, padding, border, width, height img img img p p img li
  • 26. Posicionamento + CSS: position • Atributo position: fixed • Ref.: janela (navegador) – Não rola c/ documento • Espaçamento – margin, left, right, top bottom • Tamanho – Conteúdo, padding, border, width, height img img img p p img li
  • 27. Posicionamento + CSS: position • Atributo position: fixed • Ref.: janela (navegador) – Não rola c/ documento • Espaçamento – margin, left, right, top bottom • Tamanho – Conteúdo, padding, border, width, height img img img p p img li
  • 28. Posicionamento + CSS: position • Atributo position: fixed • Ref.: janela (navegador) – Não rola c/ documento • Espaçamento – margin, left, right, top bottom • Tamanho – Conteúdo, padding, border, width, height img img img p p img li
  • 29. POSICIONAMENTO COM O CSS: ELEMENTOS “PRESOS” ÀS LATERAIS
  • 30. Posicionamento + CSS: float • Atributo float: none • Seguida a regra normal do posicionamento img p p p
  • 31. Posicionamento + CSS: float • Atributo float: left • Elmento “gruda” na lateral... E os outros elementos “escorrem” à sua volta p p p img
  • 32. Posicionamento + CSS: float • Atributo float: right • Elmento “gruda” na lateral... E os outros elementos “escorrem” à sua volta p p p img
  • 33. POSICIONAMENTO COM O CSS: MODIFICANDO A FORMA DE APRESENTAÇÃO
  • 34. Posicionamento + CSS: display • Sem atributo display: block • Apresenta elemento como previsto • Listas, por exemplo ul li li li li
  • 35. Posicionamento + CSS: display • Sem atributo display: inline / inline-block • Apresenta elementos em linha • Por exemplo, listas ul li li li li
  • 36. Posicionamento + CSS: display • Sem atributo display: none • Some com elementos ul li li li li
  • 38. Entendendo o posicionamento... • Acompanhe o professor com o código “pos” para entender o mecanismo...