-
Notifications
You must be signed in to change notification settings - Fork 0
/
posicionamento_css_parte_2.html
executable file
·228 lines (211 loc) · 7.7 KB
/
posicionamento_css_parte_2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="HTML,CSS">
<meta name="author" content="Alexandre Gomes de Lima">
<link href='http://fonts.googleapis.com/css?family=Inconsolata:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="estilos/aulas.css">
<title>IFRN/DIATINF/Design Web: Posicionamento CSS - parte 2</title>
</head>
<body>
<div id="tudo">
<header id="cabecalho">
<img src="imagens/logo_ifrn.png"
alt="IFRN"
id="logoifrn">
<h1 class="cabecalho">
Diretoria Acadêmica de Gestão e Tecnologia da Informação
</h1>
<h2 class="cabecalho">
Disciplina de Design Web e Arquitetura da Informação
</h2>
</header>
<article id="conteudo">
<h1>Posicionamento CSS - parte 2</h1>
<p>
Nesta aula iremos conhecer a propriedade <span class="html">position</span>, a qual nos
permite um amplo controle do posicionamento dos elementos em uma página web. Os valores
suportados são <span class="html">static</span> (posicionamento estático),
<span class="html">relative</span> (posicionamento relativo), <span class="html">absolute</span>
(posicionamento absoluto), <span class="html">fixed</span>
(posicionamento fixo) e <span class="html">inherit</span>. Também serão apresentadas
as propriedades <span class="html">top</span>, <span class="html">bottom</span>,
<span class="html">left</span> e <span class="html">right</span>, as quais são
sempre utilizadas em conjunto com <span class="html">position</span>.
</p>
<section>
<h2>Posicionamento estático</h2>
<p>
É o esquema de posicionamento padrão no qual os elementos de bloco são posicionados
na orientação vertical e os elementos de linha são posicionados na orientação horizontal.
Neste esquema, as propriedades <span class="html">top</span>, <span class="html">bottom</span>,
<span class="html">left</span> e <span class="html">right</span> não possuem qualquer efeito.
</p>
</section>
<section>
<h2>Posicionamento relativo</h2>
<p>
Este esquema desloca o elemento com base no canto superior esquerdo da sua posição original, sendo que
o espaço original do elemento é preservado. Deve ser utilizado em conjunto com as propriedades
<span class="html">top</span>, <span class="html">bottom</span>,
<span class="html">left</span> e <span class="html">right</span> para que haja algum efeito.
</p>
<pre class="html">
div{
border: solid black 1px;
margin-bottom: 5px;
}
#dois{
<strong>top: 25px;
left: 25px;
position: relative;</strong>
}
<div>
<p>DIV 1</p>
</div>
<div id="dois">
<p>DIV 2</p>
</div>
<div>
<p>DIV 3</p>
</div>
</pre>
<figure>
<img src="posicionamento_css_parte_2/exemplo01.png"
alt="Exemplo de uso de posicionamento relativo">
</figure>
<p>
A figura a seguir ilustra o exemplo anterior mas com a posição original do DIV 2
desenhada na cor vermelha.
</p>
<figure>
<img src="posicionamento_css_parte_2/exemplo01B.png"
alt="Exemplo de uso de posicionamento relativo com ilustração da posição original">
</figure>
<p>
Convém lembrar que o posicionamento relativo também é aplicável aos elementos de linha.
</p>
</section>
<section>
<h2>Posicionamento absoluto</h2>
<p>
O posicionamento absoluto desloca o elemento com base no canto superior esquerdo do seu
ancestral mais próximo que não esteja posicionado de forma estática.
Caso esta condição não seja atendida, o elemento é deslocado em relação ao canto superior
esquerdo da janela do navegador web. O espaço original do elemento não é preservado.
</p>
<pre class="html">
div{
border: solid black 1px;
margin-bottom: 10px;
padding: 10px;
height: 100px;
}
#b{
position: relative;
}
#c{
<strong>position: absolute;
top: 25px;
left: 60px;</strong>
height: 50px;
}
<div></div>
<div id="b">
<div id="c">C</div>
</div>
</pre>
<figure>
<img src="posicionamento_css_parte_2/exemplo02.png"
alt="Exemplo de uso de posicionamento absoluto">
</figure>
</section>
<section>
<h2>Posicionamento fixo</h2>
<p>
Neste esquema o elemento permance fixo em relação à janela do navegador. Isto significa que
mesmo que a página seja rolada, o elemento permance na mesma posição. Para verificar,
experimente o exemplo a seguir.
</p>
<pre class="html">
div{
border: solid black 1px;
margin-bottom: 10px;
}
#fixo{
background-color: pink;
<strong>position: fixed;</strong>
}
#texto{
width: 120%;
font-size: 300%;
}
<div id="fixo"><p>DIV com posicionamento fixo</p></div>
<div id="texto">
<pre>
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
x
z
</pre>
</div>
</pre>
<figure>
<img src="posicionamento_css_parte_2/exemplo03.png"
alt="Exemplo de uso de posicionamento fixo">
</figure>
</section>
<section>
<h2>Exercícios</h2>
<div class="exercicios">
<p>
1) Crie uma página HTML com um layout semelhante ao apresentado na figura abaixo. Utilize
<span class="html">div</span>s para definir as três áreas da página e a propriedade
<span class="html">position</span> para realizar o posicionamento destas áreas
(OBS: não utilize a propriedade <span class="html">float</span>).
</p>
<figure>
<img src="posicionamento_css_parte_2/exercicio01.png"
alt="Layout a ser obtido no exercício 1.">
</figure>
</div>
</section>
<section>
<h2 class="referencias">Referências</h2>
<ul>
<li class="referencia">
SILVA, Maurício Samy. <em class="referencia">Construindo sites com CSS e (X)HTML: sites controlados
por folhas de estilo em cascata</em>. São Paulo: Novatec, 2008.
</li>
<li class="referencia">
W3Schools. <em class="referencia">CSS Layout: the position property</em>.
Disponível em <a href="https://www.w3schools.com/css/css_positioning.asp"><https://www.w3schools.com/css/css_positioning.asp></a>.
</li>
</ul>
</section>
</article>
</div>
</body>
</html>