Introduction:
Basic Syntax:
@media (condition) {
/* CSS rules */
}
Common Conditions:
min-width
and max-width
):
@media (min-width: 600px)
: Applies styles if the screen is at least 600px wide.@media (max-width: 600px)
: Applies styles if the screen is no wider than 600px.orientation
):
@media (orientation: landscape)
: Applies styles if the device is in landscape mode.@media (orientation: portrait)
: Applies styles if the device is in portrait mode.min-resolution
and max-resolution
):
@media (min-resolution: 300dpi)
: Applies styles if the screen resolution is at least 300dpi.Example:
/* Default styles */
body {
background-color: white;
}
/* Styles for screens wider than 600px */
@media (min-width: 600px) {
body {
background-color: lightgray;
}
}
Use Cases:
Introduction:
Basic Syntax:
selector {
transition: property duration timing-function delay;
}
Components:
opacity
, transform
, background-color
).2s
for 2 seconds).ease
, linear
, ease-in
, ease-out
).Example:
.button {
background-color: blue;
transition: background-color 0.3s ease-in-out;
}
.button:hover {
background-color: green;
}
Use Cases:
Introduction:
transform
property in CSS allows you to apply 2D or 3D transformations to elements, such as rotating, scaling, translating, or skewing.Basic Syntax:
selector {
transform: transformation-function(value);
}
Common Transformation Functions:
transform: translateX(50px);
(Moves element 50px to the right)transform: translateY(50px);
(Moves element 50px down)transform: rotate(45deg);
(Rotates element by 45 degrees)transform: scale(1.5);
(Increases size by 1.5 times)transform: scaleX(2);
(Doubles the width)transform: skewX(20deg);
(Skews element 20 degrees along the X-axis)transform: skewY(20deg);
(Skews element 20 degrees along the Y-axis)Example:
.box {
transform: scale(1.2) rotate(45deg);
}
Use Cases: