Positioning in CSS allows you to display your element wherever you want on the screen

But when I was learning it, I found it little bit confusing😅

So in this thread I'll try to explain it in easiest manner with practical implementation. Let's start

THREAD🧵👇

There are 5 values that you can pass in position property

- static
- relative
- absolute
- fixed
- sticky

In this thread we will be focusing on relative and absolute positioning as both are widely used
Let's start with understanding what document flow is?

📌 Elements are displayed on the screen as they written in the HTML document

Consider the following piece of code:

H1, P, H3 and div are displayed on the screen in exact order as they written in the HTML file.
As now you know about document flow, let's start with Relative positioning

📌 Relative Position

- Relative positioning do not take an element out of document flow
- Relative positioning is relative to element's original position which can be changed using offset
🔹 Relative position is relative to itself.

For example: Consider the code and output in the attached image below

As you can see red box is shifted 100px from left because I applied left offset after giving it relative positioning
In the attached image below, the black dotted area would be the original position of red box if I don't apply position relative in it.

As you can see it proved that relative position is relative to itself
So now let me shift the blue box 100px towards left. So how can I do that? it's simple

.blue {
position: relative;
right: 100px;
}

Notice here that document flow is as it is. So the relative position does not affect the document flow
📌 Absolute Position

- The element is removed from the normal document flow
- You can consider it as, after applying absolute position the element will no longer in the flow and no space is created for the element in the page layout
For example:

If I apply absolute position in the red box, then the red box will be out of the flow and hence no space will be allocated to it.

See the image below, red box is out of flow and hence yellow box is at top and followed by green and blue

* Yellow box is below red
- The absolute position of an element is relative to its closest ancestor, which has some position property.

Consider the code below, Red is the parent div and black is the child div. In this particular case, body is the parent of red div
Now let me apply relative position to red(parent) div and absolute position to black(child) div.

As I mentioned absolute position is relative to closest ancestor having some position property
Let's understand it in little more details👇

Consider this piece of code.

Here green div is a parent of red and red div is a parent of black
So let me apply position property in green and black. In black div we have absolute position so in that case black div will be relative to green not red

Because here black's closest ancestor is green which has some position property
I think that's pretty much it for this thread. I hope you get a overview of CSS positioning

This may sound a bit confusing but try to play with code. You'll be able to build better understanding😄

Feel free to post your doubts below❤️

More from Pratham 👨‍💻🚀

5 great gradient background sites for every web developer and designer 🎨

🧵👇🏻


1️⃣ uiGradients

- A handpicked collection of beautiful color gradients for designers and developers.

🔗
https://t.co/EainhiePop


2️⃣ Eggradient

- Ready to use gradient background colors. ✓ Cool Gradients are prepared according to the latest design trends

🔗 https://t.co/F0uYVsZbA4


3️⃣ Mesh Gradients

- Create beautiful gradient like aurora UI in few clicks

🔗 https://t.co/MV8PT7q3Kz


4️⃣ CSS Gradient

- Create beatiful gradeint either linear or radial on different angles

🔗 https://t.co/dlCExilHAT
9 websites that will help you learn web development faster (they are free) 🧵

1. How HTTP Works

Everything you need to know about HTTP based system.

🔗
https://t.co/gVZS4RzS1a


2. 30 Days of Node

Learn Node step by step with interactive examples and code snippet in 30 days.

🔗 https://t.co/9nbtMiNB1C


3. How DNS Works

Learn what happens when you type a website address in your browser

🔗 https://t.co/SqMRNnDbc3


4. Git

Check out this excellent free website to learn git visually.

🔗 https://t.co/rQJMISBDfS
5 great code snippet websites for every web developer and designer

🧵👇🏻


1️⃣ 30 Seconds of Code

- Short code snippets for all your development needs

🔗
https://t.co/91L4bAxkgF


2️⃣ Free Frontend

- Free hand-picked HTML, CSS and JavaScript (jQuery, React, Vue) code examples, tutorials and articles

🔗 https://t.co/2sIAm73EdZ


3️⃣ Little Snippets

- A free collection of HTML and CSS code snippets

🔗 https://t.co/qxAyA2wA6U


4️⃣ CSS Deck

- Collection of Awesome CSS and JS Creations to help out frontend developers and designers.

🔗 https://t.co/LcZYnipvCy
JavaScript is powerful.

But sometimes, you can do great things using CSS.

A long thread of CSS tips and tricks:

1. Smooth


2. Change marker styling


3. Add styling to video


4. Change input caret

More from Tech

(1) Some haters of #Cardano are not only bag holders but also imperative developers.

If you are an imperative programmers you know that Plutus is not the most intuitive -> (https://t.co/m3fzq7rJYb)

It is, however, intuitive for people with IT financial background, e.g. banks

(2)

IELE + k framework will be a real game changer because there will be DSLs (Domain Specific Languages) in any programming language supported by K framework. The only issue is that we need to wait for all this

(3) Good news is that the moment we get IELE integrated into Cardano, we get some popular langs. To my knowledge we should get from day one: Solidity and Rust, maybe others as well?

List of langs:
https://t.co/0uj1eBfrYj, some commits from many years ago..

@rv_inc ?

#Cardano

(a) Last but not least, marketing to people with Haskell, functional programming with experience and decision makers in banks is a tricky one, how do you market but not tell them you want to replace them. In the end one strategy is to pitch new markets, e.g. developing world

(b) As banks realize what is happening they maybe more inclined to join - not because they would like to but because they will have to - in such cases some development talent maybe re-routed to Plutus / Cardano / Algorand / Tezos

You May Also Like

Trump is gonna let the Mueller investigation end all on it's own. It's obvious. All the hysteria of the past 2 weeks about his supposed impending firing of Mueller was a distraction. He was never going to fire Mueller and he's not going to


Mueller's officially end his investigation all on his own and he's gonna say he found no evidence of Trump campaign/Russian collusion during the 2016 election.

Democrats & DNC Media are going to LITERALLY have nothing coherent to say in response to that.

Mueller's team was 100% partisan.

That's why it's brilliant. NOBODY will be able to claim this team of partisan Democrats didn't go the EXTRA 20 MILES looking for ANY evidence they could find of Trump campaign/Russian collusion during the 2016 election

They looked high.

They looked low.

They looked underneath every rock, behind every tree, into every bush.

And they found...NOTHING.

Those saying Mueller will file obstruction charges against Trump: laughable.

What documents did Trump tell the Mueller team it couldn't have? What witnesses were withheld and never interviewed?

THERE WEREN'T ANY.

Mueller got full 100% cooperation as the record will show.