Escolar Documentos
Profissional Documentos
Cultura Documentos
Introdução CSS
Felipe Thomas
Cascading Style Sheets (CSS)
Folhas de Estilo em Cascata
4
Principal Objetivo do CSS
5
Antes do CSS...
- Criado em 1994
- Håkon Wium Lie
- Trabalhava no CERN com o
criador do HTML
- Lançada mesmo em 1996
- Suporte no IE3
9
CSS inline
- Testem aí...
<p style="color:#ff0000; font-size:48px; font-weight:bold;
background-color:#0000ff; width:300px;"> Este é um parágrafo!
</p>
10
CSS inline
11
CSS interno
12
Como colocar CSS?
• Agora o estilo não está mais direto no marcador que deve ser
customizado;
• Devemos indicar qual tag estamos estilizando;
• Para isso o CSS tem 3 elementos básicos:
13
Seletor
• { } ⇒ separador de bloco
• define o estilo do seletor anterior ao { }
• : ⇒ divide o atributo do valor
• ; ⇒ encerra um par atributo-valor
• podemos ter mais de um atributo por bloco
seletor {
atributo1 : valor-do-atributo1;
atributo2 : valor-do-atributo2;
} 15
Atributo
16
Valor do atributo
17
CSS interno
<head>
• Como que ficaria o CSS <style>
interno? p
{
• Observem que declaramos color: #ff0000;
font-size: 48px;
apenas uma vez a tag p; font-weight: bold;
background-color: #0000ff;
• Testem alterando os valores; width: 300px;
}
</style>
</head>
<body>
<p> Este é um parágrafo! </p>
<p> Este é o segundo parágrafo! </p>
</body> 18
CSS interno
19
CSS externo
20
CSS externo
<head>
<link rel="stylesheet" href="css/primeiro-estilo.css">
</head>
21
Cores
h1 { background-color: blue; }
h2 { background-color: lightblue; }
h3 { background-color: mediumblue; }
h4 { background-color: darkblue; }
body {
color: darkGrey;
}
body {
color: darkGrey;
}
body {
color: darkGrey;
}
h1 {
color: black;
}
Instituto Federal Sul-rio-grandense | câmpus Charqueadas 34
background-[alguma-coisa]
body {
background-color: black;
background-image: url("../imgs/background-repeat.jpg");
background-repeat: repeat;
background-position: right bottom;
background-attachment: fixed;
}
Instituto Federal Sul-rio-grandense | câmpus Charqueadas 35
background-image
• O que faz?
• se tirar ele, o que acontece?
• Troque body por <h1>
body {
background-color: black;
background-image: url("../imgs/background-repeat.jpg");
background-repeat: repeat;
background-position: right bottom;
background-attachment: fixed;
}
Instituto Federal Sul-rio-grandense | câmpus Charqueadas 36
background-repeat
• O que faz?
• se tirar ele, o que acontece?
• Tentem o valor com repeat, repeat-x, repeat-y, no-repeat
body {
background-color: black;
background-image: url("../imgs/background-repeat.jpg");
background-repeat: repeat;
background-position: right bottom;
background-attachment: fixed;
}
Instituto Federal Sul-rio-grandense | câmpus Charqueadas 37
background-repeat
• Padrão é repeat
• repete x e y da página
• repeat-x ⇒ eixo x
• repeat-y ⇒ eixo y
• no-repeat ⇒ não repetir
- O que faz?
- se tirar ele, o que acontece?
body {
background-color: black;
background-image: url("../imgs/background-repeat.jpg");
background-repeat: repeat;
background-position: right bottom;
background-attachment: fixed;
}
Instituto Federal Sul-rio-grandense | câmpus Charqueadas 39
background-position
• Valor padrão é
• right top
• Conforme alterarmos a posição
• o repeat ficará diferente
body {
background-color: black;
background-image: url("../imgs/background-repeat.jpg");
background-repeat: repeat;
background-position: center center;
background-attachment: fixed;
}
Instituto Federal Sul-rio-grandense | câmpus Charqueadas 41
background-attachment
• O que faz?
• se tirar ele, o que acontece?
body {
background-color: black;
background-image: url("../imgs/background-repeat.jpg");
background-repeat: repeat;
background-position: right bottom;
background-attachment: fixed;
}
Instituto Federal Sul-rio-grandense | câmpus Charqueadas 42
background-attachment