Advanced CSS Flashcards
What does the CSS position property determine?
The CSS position property determines how an element is positioned within the document. The top, right, bottom, and left properties define the specific placement.
What are the five position types in CSS?
Static: Default; positioned according to normal document flow.
Relative: Positioned relative to its normal position; offsets can be applied.
Absolute: Positioned relative to the nearest positioned ancestor; removed from normal flow.
Fixed: Positioned relative to the viewport; does not move when scrolling.
Sticky: Toggles between relative and fixed based on scroll position.
What are media queries used for in CSS?
Media queries enable responsive design by applying styles based on device characteristics, like width or resolution.
How can media queries be used in CSS?
Apply styles conditionally with @media and @import.
Target specific media with the media= attribute.
Detect media states using JavaScript (e.g., matchMedia()).
What are common media query breakpoints and their associated devices?
320px–480px: Mobile devices
481px–768px: Tablets
769px–1024px: Small screens, laptops
1025px–1200px: Desktops
1201px+: TVs and extra-large screens
What is CSS Grid Layout?
CSS Grid Layout is a two-dimensional layout system for arranging items in rows and columns.
What are the features of CSS Grid?
Grid Template (Columns, Rows)
Auto Rows and Columns
Gap and Lines
Justify Items
What is CSS Flexbox?
CSS Flexbox is a one-dimensional layout system for efficiently aligning items in containers.
What are the key features of Flexbox?
Flexibility in space distribution
Arrangement and alignment of items
Control over order and spacing
What are the main Flexbox properties?
Direction: Defines the main-axis (row or column layout).
Wrap: Controls whether items wrap or stay on one line.
What does CSS animation do?
CSS animations allow dynamic transitions between states using the @keyframes rule.
Name a few examples of CSS animations.
2D Transform – Translate
2D Transform – Rotate
3D Transform – TranslateX
What is the @keyframes rule used for?
The @keyframes rule defines animation states, allowing transitions like changing a div’s background color gradually from red to yellow in 4 seconds.
What are CSS gradients used for?
CSS gradients provide smooth transitions between colors.
What are the types of CSS gradients?
Linear: Moves in a specific direction (e.g., top, left, diagonal).
Radial: Expands from a center point.
Conic: Rotates around a center point.