<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Uzoma Udoma Alex</title>
    <description>The latest articles on DEV Community by Uzoma Udoma Alex (@whozormah).</description>
    <link>https://dev.to/whozormah</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1099382%2Fe53f03e9-553e-40f1-9970-c69928aebc17.jpeg</url>
      <title>DEV Community: Uzoma Udoma Alex</title>
      <link>https://dev.to/whozormah</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/whozormah"/>
    <language>en</language>
    <item>
      <title>Div. Positioning (Absolute)</title>
      <dc:creator>Uzoma Udoma Alex</dc:creator>
      <pubDate>Thu, 22 Jun 2023 16:20:10 +0000</pubDate>
      <link>https://dev.to/whozormah/div-positioning-absolute-1gh4</link>
      <guid>https://dev.to/whozormah/div-positioning-absolute-1gh4</guid>
      <description>&lt;h2&gt;
  
  
  Absolute
&lt;/h2&gt;

&lt;p&gt;This article focuses on &lt;strong&gt;position: absolute,&lt;/strong&gt; however you can read my earlier articles on &lt;a href="https://dev.to/whozormah/html-elements-and-div-positioning-5a7c"&gt;position: static;&lt;/a&gt; and &lt;a href="https://dev.to/whozormah/div-positioning-relative-17bg"&gt;position: relative;&lt;/a&gt; to catch up.&lt;/p&gt;

&lt;p&gt;The positioning of a div relative to the closest containing element is what distinguishes absolute positioning from relative positioning. &lt;/p&gt;

&lt;p&gt;The absolute position can be used with other position properties such as Top, Bottom, Left, and Right to offset the div as desired.&lt;/p&gt;

&lt;p&gt;In contrast to position: relative;, position: absolute; totally removes the element from the document flow, and all other elements continue to move as if the div does not exist.&lt;/p&gt;

&lt;p&gt;Since the div's movement no longer affects the positioning of other elements, it is now responsible for stacking and overlapping.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Relative is positioned relative to itself or, better still, relative to its original location. In contrast, absolute is positioned relative to the closest parent element. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It's important to keep in mind that there are two elements to be considered using the absolute positioning.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  border: 1px solid #000;
  position: relative;
}
.box1 {
  width: 100px;
  height: 100px;
  background-color: #f00;
  position: absolute;
  top: 20px;
}
.box2 {
  width: 60px;
  height: 60px;
  background-color: #0003;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above are the CSS settings for an HTML document with two child elements (box1 and box2) and a div (container) acting as their parent div.&lt;/p&gt;

&lt;p&gt;The parent div (container) has its position property set to relative; this allows (box1) to be placed absolutely to it. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/whozormah/pen/gOQwZPq"&gt;view Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Take note of how &lt;strong&gt;Box1&lt;/strong&gt; has now shifted 20 pixels away from the top of the container div. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Recall that I said we use an absolute position, relative to the nearest parent element. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UNfGlPle--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/00yi8z0snzv5seoa05dz.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UNfGlPle--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/00yi8z0snzv5seoa05dz.PNG" alt="Box1" width="438" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens when the Parent div isn't positioned relative?&lt;/strong&gt;&lt;br&gt;
Of course, since the container div is the element's closest parent div, Box1 will still move 20 pixels away from it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yfoSQRM0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yoxjs4odftadghq5fx5p.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yfoSQRM0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yoxjs4odftadghq5fx5p.PNG" alt="No Position " width="350" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the position: relative; property associated with the container div is commented out, the distance between box1 and the container decreases. This is because box1 is now adopting the screen as its parent div.&lt;/p&gt;

&lt;p&gt;The position of Box2 will be based on the normal document flow since its position property is not set. It is positioned behind Box 1 causing stacking or overlapping. &lt;/p&gt;

&lt;p&gt;In order to manage the overlapping, one can use the CSS property &lt;strong&gt;z-index&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>frontend</category>
      <category>css</category>
    </item>
    <item>
      <title>Div. Positioning (Relative)</title>
      <dc:creator>Uzoma Udoma Alex</dc:creator>
      <pubDate>Thu, 22 Jun 2023 10:23:55 +0000</pubDate>
      <link>https://dev.to/whozormah/div-positioning-relative-17bg</link>
      <guid>https://dev.to/whozormah/div-positioning-relative-17bg</guid>
      <description>&lt;p&gt;We previously established in my &lt;a href="https://dev.to/whozormah/html-elements-and-div-positioning-5a7c"&gt;prior post&lt;/a&gt;  the static attribute of the position property. &lt;/p&gt;

&lt;p&gt;The relative attribute of the position property will be covered in detail in this article.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Relative&lt;/strong&gt;&lt;br&gt;
With the relative attribute, we may position the div using additional properties like top, left, right, and bottom, unlike the static attribute.&lt;/p&gt;

&lt;p&gt;When the div moves, based on our positioning the other elements and divs won't occupy the space left as a result of the shift. This is because even when the div moves, it maintains the original position it would have covered.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: The movement of the div is with respect to the original position of the div in the document flow.   &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The below code shows a parent div container with three children divs (box1, box2, and box3)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OhQj4vFx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zsg62e258da2ltcn0a5a.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OhQj4vFx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zsg62e258da2ltcn0a5a.PNG" alt="Code Snippet" width="800" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/whozormah/pen/ExOKxPm"&gt;View Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
  Box1
  &lt;p&gt;Observe how Box1 has now shifted 110px away from the left after the box was given the CSS position property with attribute relative, along with the other positioning properties Top and Left. &lt;br&gt;
Note: The movement to the left and away from the top wouldn't occur if the position attribute were static.  &lt;/p&gt;

&lt;/p&gt;

&lt;p&gt;
  Box2
  &lt;p&gt;There is a sizable opening for Box2 after Box1 was moved away from the top and the left side. &lt;br&gt;
However, because the position attribute for Box1 is relative, it keeps the space that the box (Box1) would have taken up in the original position.&lt;br&gt;
Box2 is therefore unable to occupy the space.  &lt;/p&gt;

&lt;/p&gt;

&lt;p&gt;
  Box3
  &lt;p&gt;Similar to Box1, Box3 has a relative position attribute and a top position property set to 10px. &lt;br&gt;
Keep in mind that the bottom of Box2 reflects the location of Box3 original top, from which the box moves downward 10px. &lt;/p&gt;

&lt;p&gt;Based on the normal document flow, the Box3 has moved from its original top position.  &lt;/p&gt;

&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m3FDR5oE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bzjh1rauwdkzp6y4ljjl.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m3FDR5oE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bzjh1rauwdkzp6y4ljjl.PNG" alt="Boxes" width="504" height="489"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I hope I was able to make the &lt;strong&gt;Position: relative;&lt;/strong&gt; property easier for you to understand 😊😊.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>css</category>
      <category>frontend</category>
    </item>
    <item>
      <title>HTML Elements and Div. Positioning</title>
      <dc:creator>Uzoma Udoma Alex</dc:creator>
      <pubDate>Sun, 11 Jun 2023 17:21:15 +0000</pubDate>
      <link>https://dev.to/whozormah/html-elements-and-div-positioning-5a7c</link>
      <guid>https://dev.to/whozormah/html-elements-and-div-positioning-5a7c</guid>
      <description>&lt;p&gt;The &lt;strong&gt;CSS&lt;/strong&gt; property called position controls the rendering of HTML elements and divs by specifying where they should appear on the screen. &lt;/p&gt;

&lt;p&gt;The Position property has five primary attributes listed as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;static &lt;/li&gt;
&lt;li&gt;relative &lt;/li&gt;
&lt;li&gt;fixed &lt;/li&gt;
&lt;li&gt;absolute &lt;/li&gt;
&lt;li&gt;sticky&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;It is important to note that all HTML elements and DIVs are positioned &lt;strong&gt;static by default&lt;/strong&gt;, but this attribute can be changed to any of the available options listed above to suit our development goal.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since all HTML elements and divs are positioned static by default, let's start by looking at how the static attribute affects the positioning of these elements. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Position: static;&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since all HTML elements and Divs have their position attribute as static by default, you might not always see this property and attribute used in those elements and Divs. &lt;/p&gt;

&lt;p&gt;Most of the time, removing the default static attribute is the reason you need to use the position property alongside other attributes other than static.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;With &lt;strong&gt;attribute static&lt;/strong&gt;, The element or div with only aligns according to the document flow. &lt;br&gt;
They do not move across the page as we desire.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Here is an illustration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/whozormah/pen/bGQdLgy"&gt;Box1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fm6ErWCD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lnkkkz4mzw6qn5f3kipy.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fm6ErWCD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lnkkkz4mzw6qn5f3kipy.PNG" alt="Static Position" width="612" height="584"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example shown, there are two divs in the HTML document's body section. The child div with the class name box1 and the parent div with the class name container. &lt;/p&gt;

&lt;p&gt;The position property of the child div (box1) includes the attribute static, along with additional attributes like top, bottom, and left that work with the position property to determine where an element should be placed in the document.&lt;/p&gt;

&lt;p&gt;The child element did not respond to the top, bottom, or left properties, as you can see.&lt;/p&gt;

&lt;p&gt;Why 😫 ?&lt;/p&gt;

&lt;p&gt;This is simply because &lt;strong&gt;static position&lt;/strong&gt; only follows the regular document flow, not our desired setting. 😎&lt;/p&gt;

&lt;p&gt;Again, if you run the code with the position attribute commented out, the outcome would be the same because the default property would still be present.&lt;/p&gt;

&lt;p&gt;[without Position Property]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box1 {
  width: 100px;
  height: 100px;
  background-color: blue;
  /*position: absolute;*/
  top: 50px; 
  left: 50px; 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(&lt;a href="https://codepen.io/whozormah/pen/qBQdxeM"&gt;https://codepen.io/whozormah/pen/qBQdxeM&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;See my next post on the relative attribute. 🙂&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>css</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
