Welcome, eager learners! In today's exciting web design lesson, we're diving into CSS positioning, transitions, and animations. These dynamic enhancements breathe life into sterile web pages, creating vibrant and interactive digital experiences. Ready to jump in? Let's go!
In CSS, the position
property controls an element's location on a web page. Here’s what different position
values do:
- Static: By default, an element is static, occupying its natural place in the flow of the document.
- Relative: A relative element can move from its natural place based on the
top
,right
,bottom
,left
properties. Other elements still behave as if it's in its original position. - Absolute: The position is set relative to the nearest positioned ancestor, not from the top of the page.
- Fixed: The element's position is "fixed" to the viewport, so it stays in the same place even when you scroll the page.
The top
, right
, bottom
, and properties are used in conjunction with all positioning types except static. For relative positioning, these properties will "push" the element from its normal position to , , , and respectively. But for absolute and fixed, they position the element at a specific distance from the respectively , , , and edge of its containing element.
