<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Untitled Publication]]></title><description><![CDATA[Untitled Publication]]></description><link>https://rjimeneztech.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 14:47:27 GMT</lastBuildDate><atom:link href="https://rjimeneztech.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[CSS - Absolute Positioning]]></title><description><![CDATA[Today, I helped a fellow student in my coding bootcamp. The main thing I took away from it the behavior of absolute positioning in CSS. 
She wanted to position a label over an image - a sort of banner that laid across the image to give it a name and ...]]></description><link>https://rjimeneztech.hashnode.dev/css-absolute-positioning</link><guid isPermaLink="true">https://rjimeneztech.hashnode.dev/css-absolute-positioning</guid><category><![CDATA[CSS]]></category><category><![CDATA[bootcamp]]></category><category><![CDATA[Blogging]]></category><category><![CDATA[Developer Blogging]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Robert Jimenez]]></dc:creator><pubDate>Sat, 12 Mar 2022 06:25:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1647065717147/vLk09INJZ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Today, I helped a fellow student in my coding bootcamp. The main thing I took away from it the behavior of absolute positioning in CSS. </p>
<p>She wanted to position a label over an image - a sort of banner that laid across the image to give it a name and some flare.  Like this: 
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1647065717147/vLk09INJZ.png" alt="Screenshot 2022-03-12 001422.png" /></p>
<p>So we created a container element with another element within it that we will control the position of. The HTML looked something like this:</p>
<pre><code><span class="hljs-operator">&lt;</span>div class<span class="hljs-operator">=</span><span class="hljs-string">"container"</span><span class="hljs-operator">&gt;</span>
     <span class="hljs-operator">&lt;</span>div class<span class="hljs-operator">=</span><span class="hljs-string">"move-me"</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>p<span class="hljs-operator">&gt;</span>
               Image Name Here
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>p<span class="hljs-operator">&gt;</span>
     <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
</code></pre><p>Simple enough. </p>
<p>To painlessly position a child element within a parent element, we needed to add the "position: absolute" property to the child element. Then, we simply position the child element with any number of CSS properties (top, right, bottom, left, etc.) to get it in the right spot. </p>
<pre><code><span class="hljs-selector-class">.move-me</span> {
     <span class="hljs-attribute">position</span>: absolute;
     <span class="hljs-attribute">left</span>: <span class="hljs-number">0</span>;
     <span class="hljs-attribute">top</span>: <span class="hljs-number">50%</span>;
}
</code></pre><p>This is where it gets interesting. If we ONLY, add the absolute positioning property to the child element, we don't get what we expected. The parent element (the "container" class, in this example), needs to have the "position: relative" property. </p>
<p>That's because the "position: absolute" property only gives the freedom we expected inside the nearest positioned ancestor. Otherwise, the element defaults to being relative to the document body. So we add relative positioning to the parent/container element.</p>
<p>Our CSS looked something like this: </p>
<pre><code><span class="hljs-selector-class">.container</span> {
     <span class="hljs-attribute">position</span>: relative;
}

<span class="hljs-selector-class">.move-me</span> {
     <span class="hljs-attribute">position</span>: absolute;
     <span class="hljs-attribute">left</span>: <span class="hljs-number">0</span>;
     <span class="hljs-attribute">top</span>: <span class="hljs-number">50%</span>;
}
</code></pre><p>To take full advantage of the flexibility of "position: absolute" we needed to add "position: relative" to the container element. Something worth remembering. </p>
<p>Here is the GitHub repository to see the CSS in action: </p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://github.com/RJimenezTech/Robert-Jimenez-Porftolio">https://github.com/RJimenezTech/Robert-Jimenez-Porftolio</a></div>
<p>Check out my version of the deployed site here: </p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://rjimeneztech.github.io/Robert-Jimenez-Porftolio/">https://rjimeneztech.github.io/Robert-Jimenez-Porftolio/</a></div>
<p>Thanks for reading, 
Robert </p>
]]></content:encoded></item></channel></rss>