{"id":38246,"date":"2025-08-22T14:51:19","date_gmt":"2025-08-22T17:51:19","guid":{"rendered":"https:\/\/www.locaweb.com.br\/ajuda\/?post_type=ht_kb&#038;p=38246"},"modified":"2025-08-22T14:51:19","modified_gmt":"2025-08-22T17:51:19","slug":"position-css","status":"publish","type":"ht_kb","link":"https:\/\/www.locaweb.com.br\/ajuda\/wiki\/position-css\/","title":{"rendered":"Position CSS: entenda como usar a propriedade"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">A propriedade <\/span><b>position CSS<\/b><span style=\"font-weight: 400;\"> \u00e9 essencial para controlar o posicionamento de elementos em uma p\u00e1gina. Saber como ela funciona ajuda a construir layouts mais organizados e funcionais.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Hoje, entenderemos seus diferentes valores, veremos alguns exemplos pr\u00e1ticos, boas pr\u00e1ticas e como ela impacta a acessibilidade.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">O que \u00e9 a propriedade position no CSS?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">A propriedade<\/span> <span style=\"font-weight: 400;\">position no <\/span><a href=\"https:\/\/www.locaweb.com.br\/blog\/temas\/codigo-aberto\/css\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">CSS<\/span><\/a><span style=\"font-weight: 400;\"> define como um elemento \u00e9 posicionado dentro do documento. Ela determina<\/span><b> se o elemento seguir\u00e1 o fluxo padr\u00e3o da p\u00e1gina ou se poder\u00e1 ser movido<\/b><span style=\"font-weight: 400;\"> para posi\u00e7\u00f5es espec\u00edficas, com base em valores como <\/span><b>top<\/b><span style=\"font-weight: 400;\">,<\/span><b> right<\/b><span style=\"font-weight: 400;\">,<\/span><b> bottom<\/b><span style=\"font-weight: 400;\"> e<\/span><b> left<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Essa defini\u00e7\u00e3o \u00e9 essencial para controlar o layout e permite criar desde estruturas simples at\u00e9 composi\u00e7\u00f5es mais complexas, como menus fixos, caixas flutuantes ou elementos sobrepostos. Dessa forma, \u00e9 poss\u00edvel alterar o comportamento natural dos elementos na renderiza\u00e7\u00e3o da p\u00e1gina.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Por padr\u00e3o, todos os elementos s\u00e3o posicionados de forma est\u00e1tica e seguem a ordem do c\u00f3digo. No entanto, usar valores como <\/span><b>relative<\/b><span style=\"font-weight: 400;\">, <\/span><b>absolute<\/b><span style=\"font-weight: 400;\">, <\/span><b>fixed<\/b><span style=\"font-weight: 400;\"> e <\/span><b>sticky<\/b><span style=\"font-weight: 400;\"> facilita o controle do posicionamento.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Essa habilidade de ajustar a localiza\u00e7\u00e3o de cada parte da interface torna o <\/span><b>position<\/b><span style=\"font-weight: 400;\"> muito \u00fatil no desenvolvimento web. Com ela, d\u00e1 para criar <\/span><b>experi\u00eancias visuais mais pr\u00e1ticas, f\u00e1ceis de usar e que se adaptam<\/b><span style=\"font-weight: 400;\"> bem a diferentes tamanhos de tela e dispositivos.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-38248\" src=\"https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-1.png\" alt=\"\" width=\"720\" height=\"446\" srcset=\"https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-1.png 720w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-1-300x186.png 300w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-1-50x31.png 50w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-1-60x37.png 60w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-1-100x62.png 100w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/p>\n<h2><span style=\"font-weight: 400;\">Os diferentes valores da propriedade position<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">A propriedade position pode assumir diferentes valores, cada um com um comportamento espec\u00edfico. Entender cada um deles \u00e9 importante para controlar o layout da p\u00e1gina com efici\u00eancia.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A seguir, conhe\u00e7a os cinco principais valores: <\/span><b>static<\/b><span style=\"font-weight: 400;\">,<\/span><b> relative<\/b><span style=\"font-weight: 400;\">, <\/span><b>absolute<\/b><span style=\"font-weight: 400;\">,<\/span><b> fixed<\/b><span style=\"font-weight: 400;\"> e <\/span><b>sticky<\/b><span style=\"font-weight: 400;\">, acompanhados de exemplos pr\u00e1ticos para facilitar a visualiza\u00e7\u00e3o e a aplica\u00e7\u00e3o.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">static (Padr\u00e3o)<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">O valor static \u00e9 o padr\u00e3o de todos os elementos <\/span><a href=\"https:\/\/www.locaweb.com.br\/blog\/temas\/codigo-aberto\/html-guia-completo-sobre-a-principal-linguagem-da-internet\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">HTML<\/span><\/a><span style=\"font-weight: 400;\">, quando n\u00e3o h\u00e1 necessidade de modificar a posi\u00e7\u00e3o padr\u00e3o do elemento.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Quando n\u00e3o se define um position espec\u00edfico, o navegador aplica automaticamente esse valor. Nesse modo, o elemento \u00e9 <\/span><b>renderizado conforme a ordem natural <\/b><span style=\"font-weight: 400;\">do documento, ou seja, dentro do fluxo normal da p\u00e1gina.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Elementos com <\/span><i><span style=\"font-weight: 400;\">position: static<\/span><\/i><span style=\"font-weight: 400;\"> n\u00e3o respondem \u00e0s propriedades top, right, bottom ou left. Essas instru\u00e7\u00f5es s\u00f3 funcionam com valores de position que permitem posicionamento personalizado, como <\/span><b>relative<\/b><span style=\"font-weight: 400;\">, <\/span><b>absolute<\/b><span style=\"font-weight: 400;\">,<\/span><b> fixed<\/b><span style=\"font-weight: 400;\"> e <\/span><b>sticky<\/b><span style=\"font-weight: 400;\">.\u00a0<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Exemplo pr\u00e1tico<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Considere um bot\u00e3o que deve seguir o fluxo padr\u00e3o da p\u00e1gina para aparecer abaixo de um par\u00e1grafo. Nesse caso, n\u00e3o \u00e9 necess\u00e1rio alterar o position, pois o comportamento natural j\u00e1 atende \u00e0 estrutura desejada.<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;p&gt;Este \u00e9 um par\u00e1grafo de texto.&lt;\/p&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">&lt;button style=\"position: static;\"&gt;Clique aqui&lt;\/button&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">Mesmo que a propriedade <\/span><i><span style=\"font-weight: 400;\">position: static <\/span><\/i><span style=\"font-weight: 400;\">seja definida manualmente, o<\/span><b> resultado visual ser\u00e1 o mesmo<\/b><span style=\"font-weight: 400;\"> que n\u00e3o definir nenhuma, j\u00e1 que \u00e9 o padr\u00e3o. O bot\u00e3o ser\u00e1 exibido logo ap\u00f3s o par\u00e1grafo, sem altera\u00e7\u00e3o de posicionamento.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">relative<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">O valor relative posiciona o<\/span><b> elemento em rela\u00e7\u00e3o \u00e0 sua posi\u00e7\u00e3o original no fluxo <\/b><span style=\"font-weight: 400;\">do documento. Isso significa que o espa\u00e7o ocupado por ele continua reservado no layout, mas o elemento pode ser deslocado para outra posi\u00e7\u00e3o por meio das propriedades <\/span><b>top<\/b><span style=\"font-weight: 400;\">, <\/span><b>right<\/b><span style=\"font-weight: 400;\">, <\/span><b>bottom<\/b><span style=\"font-weight: 400;\"> e<\/span><b> left<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Esse tipo de posicionamento \u00e9 \u00fatil para movimenta\u00e7\u00f5es leves, sem alterar o comportamento dos demais \u00e0 sua volta.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Tamb\u00e9m \u00e9 comum usar relative em elementos que servir\u00e3o de refer\u00eancia para posicionar outros com absolute, j\u00e1 que absolute se baseia no elemento pai mais pr\u00f3ximo com position diferente de static.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Exemplo pr\u00e1tico<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">No exemplo abaixo, o bot\u00e3o \u00e9 deslocado 20 pixels para baixo e 30 pixels para a direita em rela\u00e7\u00e3o \u00e0 sua posi\u00e7\u00e3o original, mas o<\/span><b> espa\u00e7o reservado a ele continua<\/b><span style=\"font-weight: 400;\"> no mesmo lugar.<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;button style=\"position: relative; top: 20px; left: 30px;\"&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">\u00a0\u00a0Bot\u00e3o deslocado<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">&lt;\/button&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">O bot\u00e3o se move visualmente, mas o layout geral da p\u00e1gina n\u00e3o se ajusta ao novo local dele, o que mant\u00e9m seu espa\u00e7o original reservado.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">absolute<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">O valor absolute <\/span><b>remove completamente o elemento do fluxo normal <\/b><span style=\"font-weight: 400;\">do documento. Isso significa que ele n\u00e3o reserva espa\u00e7o na p\u00e1gina e os demais elementos se comportam como se ele n\u00e3o existisse.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">O posicionamento \u00e9 feito com base no elemento pai mais pr\u00f3ximo que tenha <\/span><i><span style=\"font-weight: 400;\">position <\/span><\/i><span style=\"font-weight: 400;\">diferente de <\/span><i><span style=\"font-weight: 400;\">static<\/span><\/i><span style=\"font-weight: 400;\">. Se nenhum antecessor estiver posicionado, o elemento ser\u00e1 posicionado em rela\u00e7\u00e3o ao &lt;<\/span><i><span style=\"font-weight: 400;\">html<\/span><\/i><span style=\"font-weight: 400;\">&gt; ou &lt;<\/span><i><span style=\"font-weight: 400;\">body<\/span><\/i><span style=\"font-weight: 400;\">&gt;.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Essa op\u00e7\u00e3o \u00e9 \u00fatil para criar elementos que<\/span><b> precisam aparecer sobre outros ou em locais espec\u00edficos <\/b><span style=\"font-weight: 400;\">da tela, como caixas de tooltip, menus suspensos ou destaques visuais.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Por estar fora do fluxo, \u00e9 poss\u00edvel controlar com precis\u00e3o sua posi\u00e7\u00e3o sem afetar os elementos ao redor.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Exemplo pr\u00e1tico<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">O exemplo abaixo mostra um bot\u00e3o posicionado absolutamente dentro de uma<\/span> <span style=\"font-weight: 400;\">div com <\/span><i><span style=\"font-weight: 400;\">position: relative<\/span><\/i><span style=\"font-weight: 400;\">, que serve como refer\u00eancia de posicionamento.<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;div style=\"position: relative; width: 200px; height: 200px; background: #f0f0f0;\"&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">\u00a0\u00a0&lt;button style=\"position: absolute; top: 10px; right: 10px;\"&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0Bot\u00e3o fixo no canto<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">\u00a0\u00a0&lt;\/button&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">&lt;\/div&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">Nesse caso, o bot\u00e3o ser\u00e1 exibido no canto superior direito da<\/span> <i><span style=\"font-weight: 400;\">div<\/span><\/i><span style=\"font-weight: 400;\">, j\u00e1 que essa <\/span><i><span style=\"font-weight: 400;\">div <\/span><\/i><span style=\"font-weight: 400;\">est\u00e1 com <\/span><i><span style=\"font-weight: 400;\">position: relative<\/span><\/i><span style=\"font-weight: 400;\">. O bot\u00e3o ignora o fluxo normal e se posiciona com base nas coordenadas definidas.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">fixed<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">O valor fixed fixa o elemento em rela\u00e7\u00e3o \u00e0 janela de visualiza\u00e7\u00e3o (viewport), independentemente do quanto a p\u00e1gina seja rolada. Isso significa que o<\/span><b> elemento sempre permanece vis\u00edvel na mesma posi\u00e7\u00e3o da tela<\/b><span style=\"font-weight: 400;\">, sem ser afetado pelo scroll.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Esse tipo de posicionamento \u00e9 bastante utilizado para criar cabe\u00e7alhos fixos, barras de navega\u00e7\u00e3o, bot\u00f5es de a\u00e7\u00e3o flutuantes ou mensagens de alerta.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Como o elemento sai completamente do fluxo do documento, ele n\u00e3o interfere nos demais elementos da p\u00e1gina e pode se sobrepor a outros conte\u00fados quando necess\u00e1rio.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Exemplo pr\u00e1tico<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">No exemplo, uma barra de navega\u00e7\u00e3o \u00e9 fixada no topo da tela. Mesmo ao rolar a p\u00e1gina, ela permanece vis\u00edvel.<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;div style=\"position: fixed; top: 0; left: 0; width: 100%; background: #333; color: white; padding: 10px;\"&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">\u00a0\u00a0Navega\u00e7\u00e3o fixa no topo<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">&lt;\/div&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">&lt;p style=\"margin-top: 60px;\"&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">\u00a0\u00a0Conte\u00fado da p\u00e1gina\u2026<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">&lt;\/p&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">A div \u00e9 posicionada no topo da janela (top: 0) e ocupa toda a largura da tela. O margin-top no conte\u00fado serve para evitar que a barra sobreponha o in\u00edcio da p\u00e1gina.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">sticky<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">O valor sticky combina comportamentos de<\/span> <span style=\"font-weight: 400;\">relative e fixed.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Inicialmente, o elemento se comporta como<\/span> <i><span style=\"font-weight: 400;\">relative<\/span><\/i><span style=\"font-weight: 400;\">, ou seja, <\/span><b>segue o fluxo normal da p\u00e1gina<\/b><span style=\"font-weight: 400;\">. Mas \u00e0 medida que a pessoa rola a p\u00e1gina, o elemento <\/span><b>se fixa em uma posi\u00e7\u00e3o espec\u00edfica dentro do seu cont\u00eainer<\/b><span style=\"font-weight: 400;\"> pai, conforme definido pelas propriedades<\/span><b> top<\/b><span style=\"font-weight: 400;\">, <\/span><b>bottom<\/b><span style=\"font-weight: 400;\">, <\/span><b>left<\/b><span style=\"font-weight: 400;\"> ou <\/span><b>right<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Esse tipo de posicionamento \u00e9 ideal para cabe\u00e7alhos de se\u00e7\u00e3o, menus laterais ou elementos que precisam permanecer vis\u00edveis por um tempo limitado durante a rolagem.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00c9 importante que o cont\u00eainer pai tenha altura suficiente para que o efeito funcione corretamente. Caso contr\u00e1rio, o sticky pode n\u00e3o se comportar como esperado.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Exemplo pr\u00e1tico<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">O exemplo mostra um cabe\u00e7alho que se fixa no topo da tela enquanto a se\u00e7\u00e3o correspondente estiver vis\u00edvel.<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;section style=\"height: 1000px;\"&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">\u00a0\u00a0&lt;h2 style=\"position: sticky; top: 0; background: white; padding: 10px; border-bottom: 1px solid #ccc;\"&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0Se\u00e7\u00e3o importante<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">\u00a0\u00a0&lt;\/h2&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">\u00a0\u00a0&lt;p&gt;Conte\u00fado longo da se\u00e7\u00e3o\u2026&lt;\/p&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">&lt;\/section&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">O <\/span><b>h2<\/b><span style=\"font-weight: 400;\"> se comporta como um elemento comum at\u00e9 que atinja o topo da janela. A partir da\u00ed, ele se fixa e acompanha o scroll, mas apenas dentro da \u00e1rea da &lt;<\/span><i><span style=\"font-weight: 400;\">section<\/span><\/i><span style=\"font-weight: 400;\">&gt;.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Quando a se\u00e7\u00e3o termina, o t\u00edtulo tamb\u00e9m sai de vista. Esse comportamento \u00e9 \u00fatil para destacar t\u00edtulos ou menus em p\u00e1ginas longas, j\u00e1 que mant\u00e9m a navega\u00e7\u00e3o clara sem ocupar espa\u00e7o o tempo todo.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Propriedades complementares para position<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Para controlar a posi\u00e7\u00e3o de um elemento que usa relative, absolute, fixed ou sticky, o CSS disponibiliza as propriedades <\/span><b>top<\/b><span style=\"font-weight: 400;\">, <\/span><b>bottom<\/b><span style=\"font-weight: 400;\">,<\/span><b> left<\/b><span style=\"font-weight: 400;\"> e<\/span><b> right<\/b><span style=\"font-weight: 400;\">.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Al\u00e9m disso, a propriedade <\/span><b>z-index <\/b><span style=\"font-weight: 400;\">permite ajustar a sobreposi\u00e7\u00e3o dos elementos na p\u00e1gina a fim de garantir que elementos posicionados apare\u00e7am em camadas espec\u00edficas quando est\u00e3o sobrepostos.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-38247\" src=\"https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image2.jpg\" alt=\"\" width=\"1395\" height=\"596\" srcset=\"https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image2.jpg 1395w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image2-300x128.jpg 300w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image2-1024x437.jpg 1024w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image2-768x328.jpg 768w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image2-50x21.jpg 50w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image2-60x26.jpg 60w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image2-100x43.jpg 100w\" sizes=\"auto, (max-width: 1395px) 100vw, 1395px\" \/><\/p>\n<h3><span style=\"font-weight: 400;\">top, bottom, left e right<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Essas quatro propriedades definem o deslocamento do elemento em rela\u00e7\u00e3o ao seu ponto de refer\u00eancia, que varia conforme o tipo de <\/span><b>position<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Com <\/span><b>relative<\/b><span style=\"font-weight: 400;\">, o deslocamento acontece em rela\u00e7\u00e3o \u00e0 posi\u00e7\u00e3o original do elemento no fluxo;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Com <\/span><b>absolute<\/b><span style=\"font-weight: 400;\">, o deslocamento \u00e9 calculado em rela\u00e7\u00e3o ao cont\u00eainer pai posicionado (n\u00e3o est\u00e1tico);<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Com <\/span><b>fixed<\/b><span style=\"font-weight: 400;\">, a refer\u00eancia \u00e9 a janela de visualiza\u00e7\u00e3o (viewport);<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Com <\/span><b>sticky<\/b><span style=\"font-weight: 400;\">, o deslocamento entra em a\u00e7\u00e3o quando o elemento atinge a posi\u00e7\u00e3o indicada durante o scroll, e permanece fixo at\u00e9 que o cont\u00eainer permita.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Essas propriedades devem ser usadas com valores como <\/span><b>px<\/b><span style=\"font-weight: 400;\">, <\/span><b>%<\/b><span style=\"font-weight: 400;\">, <\/span><b>em<\/b><span style=\"font-weight: 400;\">, entre outros, para ajustar a posi\u00e7\u00e3o com precis\u00e3o.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Quando usadas corretamente, elas ajudam a posicionar elementos em locais espec\u00edficos da p\u00e1gina sem afetar a estrutura do restante do conte\u00fado.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">z-index<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">A propriedade <\/span><b>z-index<\/b><span style=\"font-weight: 400;\"> determina a ordem em que os elementos s\u00e3o empilhados visualmente. Ela funciona apenas com elementos que possuem <\/span><b>position<\/b><span style=\"font-weight: 400;\"> diferente de <\/span><b>static<\/b><span style=\"font-weight: 400;\">. Quanto maior o valor de <\/span><b>z-index<\/b><span style=\"font-weight: 400;\">, mais acima o elemento ser\u00e1 exibido em rela\u00e7\u00e3o aos outros.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Por exemplo, se dois elementos se sobrep\u00f5em e um deles precisa ficar vis\u00edvel sobre o outro, basta definir um z-index maior para ele, como em modais, menus suspensos, tooltips e banners flutuantes.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Quando mal utilizado, por\u00e9m, ele pode causar conflitos visuais, por isso \u00e9 importante manter os valores organizados e bem planejados.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Quando usar cada tipo de position?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Escolher o tipo de position <\/span><b>depende do efeito visual e do comportamento desejado <\/b><span style=\"font-weight: 400;\">no layout. Abaixo, uma explica\u00e7\u00e3o comparativa para ajudar na escolha certa.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Valor<\/b><\/td>\n<td><b>Quando usar?<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">static<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Para elementos que seguem o fluxo normal do documento. \u00c9 o padr\u00e3o.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">relative<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Quando \u00e9 necess\u00e1rio mover o elemento levemente sem retir\u00e1-lo do fluxo.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">absolute<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Para posicionar elementos sobre outros, em rela\u00e7\u00e3o a um cont\u00eainer pai.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">fixed<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Para manter elementos fixos na tela, como cabe\u00e7alhos e bot\u00f5es flutuantes.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">sticky<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Para fixar o elemento temporariamente durante o scroll, como t\u00edtulos de se\u00e7\u00e3o.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span style=\"font-weight: 400;\">Recomenda\u00e7\u00f5es pr\u00e1ticas<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">A principal dica \u00e9 <\/span><b>n\u00e3o misturar tipos de position no mesmo cont\u00eainer<\/b><span style=\"font-weight: 400;\">, pois isso pode gerar sobreposi\u00e7\u00f5es inesperadas e dificultar a manuten\u00e7\u00e3o do layout. Al\u00e9m disso, cada um deles t\u00eam particularidades de uso.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>relative<\/b><span style=\"font-weight: 400;\">: pequenos ajustes visuais, como \u00edcones alinhados dentro de um bot\u00e3o;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>absolute<\/b><span style=\"font-weight: 400;\">: \u00e9 ideal para tooltips, pop-ups ou imagens decorativas posicionadas sobre um bloco de texto;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>fixed<\/b><span style=\"font-weight: 400;\">: funciona bem para barras de navega\u00e7\u00e3o, mensagens flutuantes ou bot\u00f5es de contato sempre vis\u00edveis;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>sticky<\/b><span style=\"font-weight: 400;\">: melhora a leitura de p\u00e1ginas longas com m\u00faltiplas se\u00e7\u00f5es, enquanto mant\u00e9m o t\u00edtulo ou menu vis\u00edvel at\u00e9 certo ponto.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Entender bem o contexto da p\u00e1gina ajuda a aplicar o tipo de position de forma<\/span><b> mais eficiente e com melhor usabilidade<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Melhores pr\u00e1ticas para layouts responsivos<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Em layouts responsivos, o uso da propriedade <\/span><b>position<\/b><span style=\"font-weight: 400;\"> deve ser planejado com cuidado. O ideal \u00e9<\/span><b> combin\u00e1-la com media queries para adaptar o posicionamento<\/b><span style=\"font-weight: 400;\"> conforme o tamanho da tela.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Por exemplo, um bot\u00e3o com position: fixed pode ser reposicionado no mobile com as propriedades <\/span><b>top<\/b><span style=\"font-weight: 400;\">, <\/span><b>bottom<\/b><span style=\"font-weight: 400;\">,<\/span><b> left<\/b><span style=\"font-weight: 400;\"> ou<\/span><b> right<\/b><span style=\"font-weight: 400;\"> dentro de uma <\/span><b>media query<\/b><span style=\"font-weight: 400;\">, para n\u00e3o cobrir conte\u00fado importante.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Al\u00e9m disso, \u00e9 recomend\u00e1vel usar position em conjunto com ferramentas modernas de layout, como Flexbox e Grid. Esses m\u00e9todos oferecem maior controle sobre a organiza\u00e7\u00e3o dos elementos e permitem criar estruturas mais flex\u00edveis.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Em muitos casos, \u00e9 poss\u00edvel resolver problemas de alinhamento com Flexbox, assim, voc\u00ea <\/span><b>reduz a necessidade de usar absolute ou relative<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Vale lembrar que \u00e9 importante evitar valores fixos de altura e largura ao usar position, principalmente em telas menores. O uso excessivo ou mal planejado de position: absolute <\/span><b>pode causar sobreposi\u00e7\u00f5es, cortes de conte\u00fado e dificuldades de leitura <\/b><span style=\"font-weight: 400;\">em dispositivos m\u00f3veis.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Sempre teste o layout em diferentes resolu\u00e7\u00f5es e, se necess\u00e1rio,<\/span><b> ajuste o comportamento com media queries<\/b><span style=\"font-weight: 400;\"> espec\u00edficas para manter a experi\u00eancia acess\u00edvel e funcional.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Como o position impacta na acessibilidade?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">A propriedade position pode afetar diretamente a experi\u00eancia de quem navega por teclado ou com leitores de tela. Isso porque, ao alterar visualmente a posi\u00e7\u00e3o de um elemento, ele pode parecer estar em um lugar diferente do que est\u00e1 na ordem l\u00f3gica do HTML.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Usar position: absolute ou fixed para mover elementos sem reorganizar o HTML pode confundir a navega\u00e7\u00e3o assistida e levar a uma experi\u00eancia inconsistente. Por isso, manter a ordem de<\/span><b> leitura coerente com a ordem visual \u00e9 essencial para garantir a acessibilidade<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Al\u00e9m disso, \u00e9 importante garantir que elementos fixos ou flutuantes, como menus ou bot\u00f5es, sejam acess\u00edveis pelo teclado e que n\u00e3o ocultem informa\u00e7\u00f5es essenciais.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">O uso adequado de z-index e aria-labels, quando necess\u00e1rio, tamb\u00e9m ajuda a garantir uma interpreta\u00e7\u00e3o correta pelas tecnologias assistivas. Com essas boas pr\u00e1ticas de posicionamento, o layout fica mais<\/span><b> inclusivo e funcional para mais pessoas<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">E se voc\u00ea precisa de uma <\/span><a href=\"https:\/\/www.locaweb.com.br\/hospedagem-de-sites-com-dominio-gratis\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">hospedagem de sites<\/span><\/a><span style=\"font-weight: 400;\"> confi\u00e1vel e robusta para seus projetos, n\u00e3o deixe de conhecer as solu\u00e7\u00f5es da Locaweb. At\u00e9 a pr\u00f3xima!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A propriedade position CSS \u00e9 essencial para controlar o posicionamento de elementos em uma p\u00e1gina. Saber como ela funciona ajuda a construir layouts mais organizados e funcionais.\u00a0 Hoje, entenderemos seus diferentes valores, veremos alguns exemplos pr\u00e1ticos, boas pr\u00e1ticas e como ela impacta a acessibilidade. O que \u00e9 a propriedade position&#8230;<\/p>\n","protected":false},"author":48,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[119],"ht-kb-tag":[],"class_list":["post-38246","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-hospedagem-de-sites"],"_links":{"self":[{"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb\/38246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/users\/48"}],"replies":[{"embeddable":true,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/comments?post=38246"}],"version-history":[{"count":1,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb\/38246\/revisions"}],"predecessor-version":[{"id":38249,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb\/38246\/revisions\/38249"}],"wp:attachment":[{"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/media?parent=38246"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb-category?post=38246"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb-tag?post=38246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}