{"id":23203,"date":"2024-03-02T17:22:28","date_gmt":"2024-03-02T16:22:28","guid":{"rendered":"https:\/\/nelkodev.com\/blog\/maquetacion-y-colocacion-de-posicionamiento-css-una-guia-completa-para-el-posicionamiento-en-css\/"},"modified":"2024-06-03T17:31:59","modified_gmt":"2024-06-03T16:31:59","slug":"maquetacion-y-colocacion-de-posicionamiento-css-una-guia-completa-para-el-posicionamiento-en-css","status":"publish","type":"post","link":"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/","title":{"rendered":"CSS Layout and Positioning: A Complete Guide to CSS Positioning"},"content":{"rendered":"<p>CSS positioning is a fundamental part of website layout. With the right positioning properties, you can control the placement and layout of elements on your page. In this article, we will explore in depth the topic of positioning in CSS and how to use it effectively in your projects. <\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ffffff;color:#ffffff\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ffffff;color:#ffffff\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#%C2%BFQue_es_el_posicionamiento_en_CSS\" >What is positioning in CSS?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#1_posicionamiento_relativo_position_relative\" >1. relative positioning (position: relative)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#2_posicionamiento_absoluto_position_absolute\" >2. absolute positioning (position: absolute)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#3_posicionamiento_fijo_position_fixed\" >3. fixed positioning (position: fixed)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#4_posicionamiento_pegajoso_position_sticky\" >4. sticky positioning (position: sticky)<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#%C2%BFComo_utilizar_el_posicionamiento_CSS_de_manera_efectiva\" >How to use CSS positioning effectively?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#1_Evita_el_uso_excesivo\" >1. Avoid excessive use<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#2_Utiliza_el_sistema_de_rejilla_grid_system\" >2. Use the grid system<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#3_Ten_en_cuenta_la_responsividad\" >3. Take into account responsiveness<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#4_Optimiza_el_rendimiento\" >4. Optimize performance<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#Preguntas_frecuentes\" >Frequently asked questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#%C2%BFCual_es_la_diferencia_entre_el_posicionamiento_relativo_y_absoluto_en_CSS\" >What is the difference between relative and absolute positioning in CSS?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#%C2%BFCuando_deberia_utilizar_el_posicionamiento_pegajoso_en_CSS\" >When should you use sticky positioning in CSS?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/nelkodev.com\/en\/blog\/layout-and-placement-of-css-positioning-a-complete-guide-to-positioning-in-css\/#%C2%BFExiste_una_propiedad_CSS_para_apilar_elementos_uno_encima_del_otro\" >Is there a CSS property to stack elements on top of each other?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"%C2%BFQue_es_el_posicionamiento_en_CSS\"><\/span>What is positioning in CSS?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Positioning in CSS refers to how elements are placed and organized on a web page. Through different properties and values, you can set the exact position of an element in relation to other elements, the document, or the browser window. This allows you to create more dynamic and personalized designs.<\/p>\n<p>There are several types of positioning in CSS, each with its own characteristics and use cases:<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_posicionamiento_relativo_position_relative\"><\/span>1. relative positioning (position: relative)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Relative positioning is the most basic type of positioning in CSS. With it, you can adjust the position of an element relative to its normal position. You can use the properties <code>top<\/code>, <code>right<\/code>, <code>bottom<\/code> y <code>left<\/code> to specify the offset of the element from its original position.<\/p>\n<p>For example:<\/p>\n<pre>\n<code>\n.element { position: relative; top: 20px; left: 50px; }\n<\/code>\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2_posicionamiento_absoluto_position_absolute\"><\/span>2. absolute positioning (position: absolute)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Absolute positioning is useful when you need to position an element precisely at a specific location on the page. The element will be positioned relative to its first parent element which has a non-standard (i.e. non-static) position.<\/p>\n<p>For example:<\/p>\n<pre>\n<code>\n.parent { position: relative; } .element { position: absolute; top: 0; right: 0; }\n<\/code>\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"3_posicionamiento_fijo_position_fixed\"><\/span>3. fixed positioning (position: fixed)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Fixed positioning is similar to absolute positioning, but the element is held fixed at a specific position relative to the browser window. Even if the user scrolls the page, the element will remain in its original position.<\/p>\n<p>For example:<\/p>\n<pre>\n<code>\n.element { position: fixed; top: 50px; left: 50px; }\n<\/code>\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"4_posicionamiento_pegajoso_position_sticky\"><\/span>4. sticky positioning (position: sticky)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Sticky positioning is a combination of relative and fixed positioning. The element behaves as relative until it reaches a specific position in the browser window, at which point it is fixed in place.<\/p>\n<p>For example:<\/p>\n<pre>\n<code>\n.element { position: sticky; top: 20px; }\n<\/code>\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%C2%BFComo_utilizar_el_posicionamiento_CSS_de_manera_efectiva\"><\/span>How to use CSS positioning effectively?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Although positioning in CSS offers great flexibility, it is important to use it effectively to avoid layout and performance issues.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Evita_el_uso_excesivo\"><\/span>1. Avoid excessive use<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It&#039;s tempting to use positioning in CSS to control every detail of your design, but this can lead to complicated and difficult to maintain code. Instead, use positioning selectively and focus on the structure and natural flow of the document.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Utiliza_el_sistema_de_rejilla_grid_system\"><\/span>2. Use the grid system<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The grid system is an efficient way to organize and position your elements in CSS. You can use frameworks like Bootstrap or create your own custom grid system.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_Ten_en_cuenta_la_responsividad\"><\/span>3. Take into account responsiveness<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Positioning in CSS should adapt to different screen sizes and devices. Use media queries to adjust the positioning according to the needs of each device.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"4_Optimiza_el_rendimiento\"><\/span>4. Optimize performance<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>CSS positioning can affect website performance. Avoid using expensive positioning properties, such as fixed positioning, on elements that move or resize frequently.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Preguntas_frecuentes\"><\/span>Frequently asked questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"%C2%BFCual_es_la_diferencia_entre_el_posicionamiento_relativo_y_absoluto_en_CSS\"><\/span>What is the difference between relative and absolute positioning in CSS?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Relative positioning adjusts the position of an element relative to its normal position, while absolute positioning places the element at a specific position relative to its first positioned parent element.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%C2%BFCuando_deberia_utilizar_el_posicionamiento_pegajoso_en_CSS\"><\/span>When should you use sticky positioning in CSS?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Sticky positioning is useful when you want an element to scroll with the user until it reaches a specific position in the browser window, at which point it is fixed in place.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%C2%BFExiste_una_propiedad_CSS_para_apilar_elementos_uno_encima_del_otro\"><\/span>Is there a CSS property to stack elements on top of each other?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Yes, you can use the z-index property to stack elements in CSS. The z-index property controls the stacking order of positioned elements.<\/p>\n<p>In conclusion, CSS positioning is a fundamental skill for any web developer. By using the different types of positioning effectively, you can create professional and personalized designs. Always remember to consider document structure and site performance to get the best results.<\/p>","protected":false},"excerpt":{"rendered":"<p>CSS positioning is a fundamental part of website layout. With the right positioning properties, you can control the placement and layout of elements on your page. In this article, we will explore the topic of CSS positioning in depth and how to use it effectively in your projects. What is CSS positioning?<\/p>","protected":false},"author":1,"featured_media":23204,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[420,1121],"tags":[205,593,500,519,358,595,60,58,37],"class_list":["post-23203","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-css","tag-blog","tag-colocacion","tag-completa","tag-css","tag-guia","tag-maquetacion","tag-para","tag-posicionamiento","tag-una"],"_links":{"self":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/posts\/23203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/comments?post=23203"}],"version-history":[{"count":0,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/posts\/23203\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/media\/23204"}],"wp:attachment":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/media?parent=23203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/categories?post=23203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/tags?post=23203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}