02. Advanced CSS
02. Advanced CSS
Advanced CSS
Outline
● Position
● Media Queries
● Grid & Flexbox
● Animation
● Gradient
Position
The position CSS property sets how an element is
positioned in a document. The top, right, bottom,
and left properties determine the final location of
positioned elements.
There are several position in css:
- Static (default)
- Relative
- Absolute
- Fixed
- Sticky
Src :
https://developer.mozilla.org/en-US/docs/Web/CSS/p
osition
Position - Static
● To conditionally apply styles with the CSS @media and @import at-rules.
● To target specific media for the <style>, <link>, <source>, and other HTML elements with the media=
attribute.
● To test and monitor media states using the Window.matchMedia() and MediaQueryList.addListener()
JavaScript methods.
Src: https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
Media Query Syntax
Example:
The following example shows a menu that will float to the left of the
page if the viewport is 480 pixels wide or wider (if the viewport is
less than 480 pixels, the menu will be on top of the content):
Common Media Query Breakpoints
There is no standard exactly defined, but these are some commonly used ones
Src : https://developer.mozilla.org/en-US/docs/Web/CSS/grid
Grid Example
Grid Example
Grid Template Columns
Grid Template Rows
Grid Template Rows
Grid Auto Rows
Grid Auto Rows
Grid Gap
Grid Gap
Grid Lines
Grid Column
Grid Column
Grid Row
Grid Justify Items
Flex
The CSS Flexbox model is a one-dimensional layout approach designed for efficiently organizing and
aligning items within a container. It offers flexibility in managing space distribution and is particularly handy
for crafting clean and responsive layouts, making it well-suited for both small-scale designs and
mobile-friendly applications.
Features of flexbox:
Src : https://developer.mozilla.org/en-US/docs/Web/CSS/flex
Flex Directions
This establishes the main-axis, thus defining the direction flex items are placed in the flex container.
Flexbox is (aside from optional wrapping) a single-direction layout concept. Think of flex items as primarily
laying out either in horizontal rows or vertical columns.
Flex-wrap
By default, flex items will all try to fit onto one line. You can change that and allow the items to wrap as
needed with this property.