惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
阮一峰的网络日志
阮一峰的网络日志
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
P
Palo Alto Networks Blog
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cisco Talos Blog
Cisco Talos Blog
L
Lohrmann on Cybersecurity
AWS News Blog
AWS News Blog
J
Java Code Geeks
博客园_首页
Scott Helme
Scott Helme
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
V
Visual Studio Blog
Cloudbric
Cloudbric
Jina AI
Jina AI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
The Last Watchdog
The Last Watchdog
SecWiki News
SecWiki News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
W
WeLiveSecurity
K
Kaspersky official blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hacker News: Ask HN
Hacker News: Ask HN
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
量子位
Google Online Security Blog
Google Online Security Blog
博客园 - Franky
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 三生石上(FineUI控件)
Recent Commits to openclaw:main
Recent Commits to openclaw:main

Maggie Appleton

The Dark Forest and Generative AI One Developer, Two Dozen Agents, Zero Alignment Gas Town’s Agent Patterns, Design Bottlenecks, and Vibecoding at Scale January 2026 | Maggie Appleton A Treatise on AI Chatbots Undermining the Enlightenment A Brief History & Ethos of the Digital Garden Vibe Code is Legacy Code May 2025 | Maggie Appleton Home-Cooked Software and Barefoot Developers Statistically, When Will My Baby Be Born? Speculative Calendar Events ChatGPT Would be a Decent Policy Advisor March 2025 | Maggie Appleton The Expanding Dark Forest and Generative AI Humanity's Last Exam Squish Meets Structure Common Misconceptions in AI Undetected AI Exam Answers Unbaited Smidgeons Growing a Human: The First 30 Weeks How to Import Academic Papers from Zotero into Tana December 2024 | Maggie Appleton Aesthetic Command Lines with Hyper, Spaceship, and Oh My Zsh Leaving Elicit July 2024 | Maggie Appleton A Short History of Bi-Directional Links The Pattern Language of Project Xanadu Assumed Audiences Ambient Co-presence On Opening Essays, Conference Talks, and Jam Jars Spinning Worlds, Seasickness, and Dealing with Vestibular Neuritis A Collection of Design Engineers Gathering Structures Daily Notes Pages Historical Trails December 2023 | Maggie Appleton September 2023 | Maggie Appleton Digital Gardening for Non-Technical Folks Language Model Sketchbook, or Why I Hate Chatbots June 2023 | Maggie Appleton Computational Notebooks Folk Interfaces Reverse Outlining with Language Models Command K Bars Spatial Web Browsing A Picture Worth a Thousand Programmes Programmable Notes Programming Portals Teenage Skeuomorphic Desktop Designs Tending Evergreen Notes in Roam Research Growing the Evergreens Why You Own an iPad and Still Can't Draw A Brief Introduction to Digital Anthropology Transclusion and Transcopyright Dreams The Block-Paved Path to Structured Data Empty Pointers and Constellations of AI Metaphors We Web By The Gift Economy Epistemic Disclosure November 2022 | Maggie Appleton Joining Ought July 2022 | Maggie Appleton The Linear Oppression of Note-taking Apps Paleolithic Nostalgia Interoperable Personal Libraries and Ad Hoc Reading Groups The Finest Narrative Non-Fiction Essays Algorithmic Transparency October 2021 | Maggie Appleton Plebeian Programming with Keyboard Maestro The Cultural Anthropology of React August 2021 | Maggie Appleton Natureculture, Moral Purity, and Cultural Boundaries The Echo & Narcissus Writing Club Pink, Soft, Glittering Developers Fetishism & Mechanical Keyboards Making Programming Visual, Spatial, and Learnable Organic, Local, Artisan Data Storage Painting Roam Research with Custom CSS A Digital Anthropology Reading List The Eponymous Laws of Programming A History of Cyborgs Neologisms GreenSock Animations with React Hooks The Bare Essentials of Greensock September 2020 | Maggie Appleton Illustrating Gatsby's Key Concepts Problematic Proteins New Harvest & Illustrating the Cultivated Meat Podcast Synecdoche: Drawing the Part for the Whole A Meta-Tour of This Site Douglas, Dirt, and Matter Out of Place The Knowledge Hydrant A Naïve Exploration of Computer-Supported Collaborative Learning Silent Synchronous Reading Sessions What the Fork is React Suspense? Visually Workshopping the AWS Cloud Are Data Unions the Future of Data? Pattern Languages in Programming and Interface Design A Metaphorical Reading Collection
Positioning Elements & Scrollytelling in CSS
Chris Coyier · 2020-12-26 · via Maggie Appleton

Notes (mostly to myself) on how the CSS position property works because I constantly forget. Specifically in relation to building scrollytelling pieces.

Having control over where elements are positioned on a webpage is essential for building scrollytelling stories. We have to understand exactly how elements will behave within the layout, especially in relation to the scrollbar and viewport.

The position property determines where an element appears on the page. Sounds simple. But it also includes how an element relates to its parent element, the browser window, how it behaves on scroll, and whether placement properties like top, right, bottom, left and z-index will have any effect.

Position has six possible values

1. Static

static is the default value for elements. They stick to the normal page flow and placement properties (top, left, z-index, etc.) don’t have any effect.

This would be the equivalent code, but we never need to explicitly declare it since all elements are static by default.

.tealBox {
	position: static;
}

2. Relative

relative keeps the element in the normal document flow, but allows us to use placement properties. This means we can move the element up, down, left or right, relative to where it would have been in the normal document flow.

For example, if we nudge this box -20px up, and -20px to the left, it moves to here:

/>

In our CSS we would just need to declare a relative property on our box, then add top and left properties:

.tealBox {
	position: relative;
	top: -10px;
	left: -10px;
}

3. Absolute

absolute removes the element from the normal document flow. It places itself on an absolute position relative to the whole document.

The position of the parent has no influence on where the child shows up. Placement values like top and left are calculated relative to the document.

Declaring position: absolute, left: 20px and bottom: 20px on this .tealBox element would position it 20 pixels from the left and 20px from the bottom of the document.

.tealBox {
	position: absolute;
	left: 20px;
	bottom: 20px;
}

Relative Parents and Absolute children

If you declare position: relative on the parent element, and position: absolute on the child, it now positions itself relative to the parent.

This is useful for creating overlapping elements.

.parent {
	position: relative;
}
.tealBox {
	position: absolute;
	left: 20px;
	bottom: 20px;
}

4. Fixed

fixed is similar to absolute, but sticks itself to the viewport (the browser window) rather than the document. Fixed elements don’t move when you scroll down the page - they are always visible.

Fixed is useful for persistent elements like navigation bars or menus.

Declaring position: fixed;, top: 20px; and right: 20px on an element will position it 20 px from the top and right-hand side of the browser viewport. The rest of the document scrolls behind it.

.tealBox {
	position: fixed;
	top: 20px;
	right: 20px;
}

An Annoying Transform Quirk

If any parent element has a transform: translate() property declared on it, fixed won’t work.

5. Sticky

sticky makes an element “stick” to the viewport (the browser window) when it reaches a certain point – usually when the top of the viewport hits the top of the element.

It behaves like a relative element until it hits the sticking point, and then becomes fixed.

For sticky to work, the parent element needs to have the relative property declared.

.parent {
	position: relative;
}
.tealBox {
	position: sticky;
	top: 150px; /* Box becomes sticky when the top of
  the viewport is 150px away from the top of the box  */
}

6. Inherit

inherit forces an element to inherit the position property of its parent. This wouldn’t otherwise happen as position doesn’t flow down the cascade.

References and Further Reading