Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
CSS
(Cascading Style Sheets)
<html>
<head>
<title>Exemplo</title>
</head>
<body style="background-color: #FF0000;">
<p>Esta uma pgina com fundo vermelho</p>
</body>
</html>
Mtodo 2: Interno (a tag style)
<html>
<head>
<title>Exemplo</title>
<style type="text/css">
body { background-color: #FF0000;}
</style>
</head>
<body>
<p>Esta uma pgina com fundo vermelho</p>
</body>
</html>
Mtodo 3: Externo
(link para uma folha de estilos)
<html>
<head>
<title>Meu documento</title>
<link rel="stylesheet" type="text/css"
href="style/style.css">
</head>
</html>
Comentrios em CSS
PRTICA
Dentro do editor, crie dois arquivos (um HTML e um CSS) com os
seguintes contedos:
Index.html
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Meu documento</title>
<link rel="stylesheet" type="text/css" href="estilo.css" />
</head>
<body>
<h1>Minha primeira folha de estilos</h1>
</body>
</html>
estilo.css
body {
background-color: #FF0000;
}
body {
background-color: #FFCC66;
}
h1{
color: #990000
background-color: #FC9804
}
2.2. Imagens de fundo [background-image]
body {
background-color: #FFCC66;
background-image: url ("imagem.gif");
}
h1{
color: #990000;
background-color: #FC9804;
}
2.3. Imagem de fundo repetida
[background-repeat]
VALOR DESCRIO
body {
background-color: #FFCC66;
background-image: url(imagem.gif");
background-repeat: no-repeat;
}
h1 {
color: #990000;
background-color: #FC9804;
}
2.4. Imagem de fundo fixa
[background-attachment]
VALOR DESCRIO
25% 25%
50% 50%
center center
100% 100%
bottom right
EXEMPLO:
body {
background-color: #FFCC66;
background-image: url(imagem.gif");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: right bottom;
}
h1 { color: #990000;
background-color: #FC9804;
}
Compilando [background]
background-color: #FFCC66;
background-image: url(imagem.gif");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: right bottom;
}
3. Fontes
3.1. Famlia de fontes [font-family]
3.2. Estilo da fonte [font-style]
h1 {
font-family: arial, verdana, sans-serif;
}
h2 {
font-family: "Times New Roman", serif;
font-style: italic;
}
3.3. Fonte variante [font-variant]
p {
font: italic bold 30px arial, sans-serif;
}
4. Textos
4.1. Indentao de texto [text-indent]
P{
text-indent: 30px;
}
4.2. Alinhamento de textos [text-align]
h1 {
letter-spacing: 6px;
}
p {
letter-spacing: 3px;
}
4.5. Transformao de textos [text-transform]
capitalize
Exemplo: "john doe" transforma-se para "John Doe".
uppercase
Exemplo: "john doe" transforma-se para "JOHN DOE".
lowercase
Exemplo: "JOHN DOE" transforma-se para "john doe".
none
Sem trasformaes - o texto apresentado como foi escrito
no cdigo HTML.
5. Links
CSS
a { color: blue; }
a.whitewine { color: #FFBB00; }
a.redwine { color: #800000;}
6.2. Identificando um elemento com uso de id
#c1-1 {
color: red;
}
6.3. Agrupando elementos com <span>
.disciplina {
font-style: italic; font-weight: bold;
color: blue
}
Disciplina: <span
class="disciplina">Informatica</span>
6.4. Agrupando com <div>
<div id=resumo>
Disciplina: <span class="disciplina">Autoria
Web</span>
</div>
#resumo{
border-style: dashed;
border-width: 3px;
border-color: red;
}
7. Box Model
As CSS considera e trata todos dos elementos HTML
como se fossem caixas.
body {
margin-top: 100px;
margin-right: 40px;
margin-bottom: 10px;
margin-left: 70px; }
h2 { border-width: 20px;
border-style: outset; border-
color: red; }
p { border-width: 1px;
border-style: dashed; border-
color: blue; }
ul { border-width: thin;
border-style: solid; border-
color: orange; }
8.4. Atribuindo largura [width]
div.box {
width: 200px;
border: 1px solid black;
background: orange;
}
#box1 {
position:absolute;
top: 50px;
left: 50px;
}
10.2. Posicionamento relativo
#bola1 {
position:relative;
left: 350px;
bottom: 150px;
}
Motivao para o uso do CSS
Economiza-se tempo de criao e manuteno
(isola os cdigos de formatao aplicado a vrias
pginas HTML em um nico arquivo ".css");
Reduz cdigo de descritores HTML da pgina
(tags);
Os navegadores (browsers) carregam mais
rpido;
Maior eficincia no gerenciamento do layout;
CSS simples pois descreve apenas estilos.
DVIDAS???