### grid-row-start example
Source: https://css-tricks.com/almanac/properties/g/grid-area
Example of setting the starting row line for a grid item.
```css
.element { grid-row-start: 2; }
```
--------------------------------
### margin-block-start Usage Example
Source: https://css-tricks.com/almanac/properties/m/margin/margin-inline
Shows how to set the logical block start margin.
```css
.element { margin-block-start: 25%; }
```
--------------------------------
### Full CSS Example with Nested Style Queries
Source: https://css-tricks.com/almanac/rules/c/container
A comprehensive CSS example demonstrating container setup, nested style queries for different themes (purple and orange), and aesthetic styling for parent and child elements.
```css
.parent {
container-name: cards;
container-type: inline-size;
}
@container cards (width > 600px) {
@container style(--theme: purple) {
.child {
background-color: #cb6ce6;
}
}
@container style(--theme: orange) {
.child {
background-color: #f7941f;
}
}
}
/* Aesthetic Changes */
:root {
--spacing: clamp(12px, min(5vw, 5vh), 50px);
}
* {
padding: 0px;
margin: 0px;
box-sizing: border-box;
}
html {
font-size: clamp(8px, 4vw, 18px);
}
body {
display: flex;
flex-flow: column;
gap: var(--spacing);
min-height: 100vh;
padding: var(--spacing);
font-family: monospace;
}
.parent,
.child {
display: flex;
flex-flow: column;
gap: var(--spacing);
flex: 1 1;
padding: var(--spacing);
border: 3.5px solid #372f3b;
border-radius: 10px;
box-shadow: 0px 9px 0px -3px #fff9, 0px 9px 0px 0px #372f3b,
-4px 14px 4px 4px #0005, inset -4px -4px 4px 4px rgba(0, 0, 0, 0.15);
}
.parent {
resize: horizontal;
overflow-x: hidden;
}
.parent:first-child {
width: 50%;
}
span {
text-align: center;
}
@container cards (width > 600px) {
@container style(--theme: purple) {
.child {
box-shadow: 0px 9px 0px -3px #cb6ce6a0, 0px 9px 0px 0px #372f3b,
-4px 14px 4px 4px #0005, inset -4px -4px 4px 4px rgba(0, 0, 0, 0.15);
}
}
@container style(--theme: orange) {
.child {
box-shadow: 0px 9px 0px -3px #f7941fa0, 0px 9px 0px 0px #372f3b,
-4px 14px 4px 4px #0005, inset -4px -4px 4px 4px rgba(0, 0, 0, 0.15);
}
}
}
```
--------------------------------
### Equivalent to identical align-items and justify-items
Source: https://css-tricks.com/almanac/properties/p/place-items
This example demonstrates the expanded form of place-items: start, showing how it sets both align-items and justify-items to start.
```css
.item {
display: grid;
align-items: start;
justify-items: start;
}
```
--------------------------------
### Example of conic-gradient()
Source: https://css-tricks.com/almanac/functions/c/cross-fade
Shows how to create a background image using a conic gradient, starting from a 45-degree angle.
```css
.element { background-image: conic-gradient(from 45deg, white, black, white); }
```
--------------------------------
### Two-value syntax examples
Source: https://css-tricks.com/almanac/properties/a/animation-range
Demonstrates various combinations of keywords and lengths for `animation-range`, illustrating its flexibility in defining start and end points.
```css
animation-range: cover exit;
```
```css
animation-range: 20% 70%;
```
```css
animation-range: contain 20% enter;
```
```css
animation-range: contain enter 70%;
```
```css
animation-range: cover 20% exit-crossing 70%;
```
--------------------------------
### Demo Styling for linear() Examples
Source: https://css-tricks.com/almanac/functions/l/linear
Provides the necessary CSS for demonstrating the effects of various linear() timing functions, including layout and animation setup.
```css
@layer demo {
* {
padding: 0px;
margin: 0px;
box-sizing: border-box;
}
html {
font-size: clamp(10px, min(1.5vw, 1.5vh), 16px);
}
body {
display: grid;
place-items: center;
height: 100dvh;
padding: 20px;
}
ul {
display: flex;
flex-flow: column;
gap: 3rem;
width: min(100%, 800px);
}
li {
display: flex;
align-items: center;
list-style: none;
}
h1 {
width: 50ch;
font-size: 2rem;
}
.bar {
height: 50px;
width: 100%;
background: radial-gradient(
circle at left center in oklch,
tomato,
crimson
);
background-repeat: no-repeat;
}
.ruler {
display: flex;
flex-flow: row;
justify-content: space-between;
width: 100%;
font-size: 1.5rem;
}
}
```
--------------------------------
### Full CSS Example with color-mix() and Styling
Source: https://css-tricks.com/almanac/functions/c/color-mix
Complete CSS for a visual example, including body styling and the element styled with color-mix() in oklch.
```css
body {
margin: 0;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #f0f0f0;
font-family: system-ui, sans-serif;
}
.element {
width: 15rem;
height: 15rem;
background: color-mix(in oklch, red 60%, green 60%);
color: white;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
```
--------------------------------
### CSS Styling for padding-inline-start Example
Source: https://css-tricks.com/almanac/properties/p/padding/padding-inline
Complete CSS for the `padding-inline-start` example, including layout and writing mode specific styles.
```css
body {
width: 100%;
display: flex;
align-items: center;
flex-direction: column;
}
.title{
text-align: center;
font-size: 20px;
}
.container {
display: flex;
align-items: flex-start;
flex-wrap: wrap;
gap: 1em;
margin: 2em;
}
.box {
width: 200px;
height: 200px;
}
.text {
border:3px dashed #ff7a18;
padding-inline-start: 40px;
}
.horizontal-tb {
writing-mode: horizontal-tb;
}
.vertical-rl {
writing-mode: vertical-rl;
}
.vertical-lr {
writing-mode: vertical-lr;
}
```
--------------------------------
### Offsetting Animation Start with animation-range
Source: https://css-tricks.com/almanac/properties/v/view-timeline-axis
Use `animation-range` to offset the animation start point. This example offsets the animation by 500px, triggering it further to the left on the x-axis.
```css
h1 {
animation-range: 500px;
}
```
--------------------------------
### CSS Animation-Range Four-Value Syntax Examples
Source: https://css-tricks.com/almanac/properties/a/animation-range
Examples showcasing the four-value syntax for animation-range, providing distinct start and end ranges with specific keywords and lengths.
```css
animation-range: cover 0% cover 200px;
```
```css
animation-range: entry 10% exit 100%;
```
--------------------------------
### Simple text-shadow example
Source: https://css-tricks.com/almanac/properties/t/text-shadow
A basic example demonstrating a single shadow with a slight offset and transparency.
```css
.simple {
background: #91877b;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
```
--------------------------------
### CSS @counter-style for multiple start example
Source: https://css-tricks.com/almanac/rules/c/counter-style
Defines a custom counter style using multiple fixed symbols that start from the fourth item. Applied to elements with the 'multiple-start' class.
```css
@counter-style multiple-start-example {
system: fixed 4;
symbols: "๐งก" "๐" "๐" "๐";
suffix: " ";
}
```
--------------------------------
### Complete CSS for drop-shadow() Example
Source: https://css-tricks.com/almanac/functions/d/drop-shadow
Full CSS for the drop-shadow() example, including styling for the element and body, to create a visual demonstration.
```css
.box {
filter:
drop-shadow(0 2.8px 2.2px rgb(0 0 0 / 0.034))
drop-shadow(0 6.7px 5.3px rgb(0 0 0 / 0.048))
drop-shadow(0 12.5px 10px rgb(0 0 0 / 0.06))
drop-shadow(0 22.3px 17.9px rgb(0 0 0 / 0.072))
drop-shadow(0 41.8px 33.4px rgb(0 0 0 / 0.086));
min-height: 200px;
width: 50vw;
margin: 100px auto;
background: white;
border-radius: 5px;
}
body {
background: #EEF2F7;
}
```
--------------------------------
### Example: Supports Display Grid
Source: https://css-tricks.com/almanac/rules/s/supports
A basic example demonstrating how to check for support of the 'display: grid' property-value pair.
```css
@supports (display: grid) {
/* Styles */
}
```
--------------------------------
### CSS page-break-before Example
Source: https://css-tricks.com/almanac/properties/b/break-after
Demonstrates forcing a page break before an element, commonly used for section starts.
```css
.element { page-break-before: always; }
```
--------------------------------
### Complete Example with Styling
Source: https://css-tricks.com/almanac/rules/k/keyframes
A comprehensive example demonstrating the 'spin' keyframes animation applied to an image, including basic HTML structure and aesthetic styling for centering and sizing the image.
```css
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(720deg);
}
}
img {
animation: spin 1s infinite;
}
/* Aesthetic Styles */
* {
margin: 0;
padding: 0;
}
html {
font-family: monospace;
font-weight: 600;
font-size: 16px;
}
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
img {
height: clamp(100px, min(20vw, 20vh), 200px);
}
```
--------------------------------
### CSS @media Example
Source: https://css-tricks.com/almanac/rules/i/import
Shows a basic example of a CSS media query to apply styles based on screen width.
```css
@media screen and (min-width: 600px) { }
```
--------------------------------
### Counters with Initial Count Set
Source: https://css-tricks.com/almanac/functions/c/counters
This example demonstrates how to set an initial count for counters. It resets all ordered lists to start at 0, but then overrides the first-level ordered list to start at 4. List items are then incremented.
```css
.different-initial {
/* Sets all counters */
ol {
counter-reset: item;
}
/* Overrides first */
& > ol {
counter-reset: item 4;
}
li {
counter-increment: item;
}
li::marker {
content: counters(item, ".") ") ";
}
}
```
--------------------------------
### Full Demo with Resizable Container
Source: https://css-tricks.com/almanac/properties/p/position-try-order
A comprehensive example demonstrating anchor positioning with fallbacks and order, including a resizable main container to test responsiveness.
```html
Your browser doesn't support this demo. It is only supported in Chrome 125+
anchor
target
```
```css
.anchor {
anchor-name: --my-anchor;
}
.target {
position: absolute;
position-anchor: --my-anchor;
position-area: top right;
position-try-fallbacks: flip-block;
position-try-order: most-height;
width: 100%;
height: 100%;
}
/* Aesthetic Changes */
:root {
--anchor-size: clamp(40px, 10vh, 80px);
}
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body {
display: flex;
flex-flow: row-reverse wrap;
justify-content: center;
align-items: center;
gap: 40px;
padding: 20px;
min-height: 100vh;
font-family: monospace;
}
main {
display: flex;
align-items: start;
justify-content: start;
padding: calc(var(--anchor-size) * 2) 0px 0px calc(var(--anchor-size) * 2);
border: 2px solid black;
border-radius: 10px;
height: calc(var(--anchor-size) * 5);
aspect-ratio: 1;
position: relative;
resize: both;
overflow: hidden;
}
.anchor {
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
width: var(--anchor-size);
aspect-ratio: 1;
background-color: #ffbd59;
}
.target {
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
background-color: #cb6ce6;
}
.not-supported {
position: fixed;
top: 0;
left: 0;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 40px;
font-weight: 600;
background-color: #ffbd59aa;
}
@supports (position-try-options: flip-block) {
.target {
position-try-options: flip-block;
}
}
@supports (inset-area: top right) {
.target {
inset-area: top right;
}
}
@supports (position-area: top right) or (inset-area: top right) {
.not-supported {
display: none;
}
}
```
--------------------------------
### Full example with named grid areas
Source: https://css-tricks.com/almanac/properties/g/grid-row/grid-row-start
Demonstrates setting up a grid with named areas and positioning the header element using `grid-row-start`.
```html
```
```css
body {
display: grid;
grid-template-rows: min-content 1fr min-content;
grid-template-areas:
"header"
"main"
"footer";
}
header {
grid-row-start: header;
}
```
--------------------------------
### Basic Scroll-timeline-axis Usage Example
Source: https://css-tricks.com/almanac/properties/s/scroll-timeline-axis
This example shows a complete setup for scroll-driven animations, including naming the timeline, setting the axis to horizontal scroll, and referencing the timeline in the animation property. Ensure 'animation-timeline' is set after 'animation'.
```css
.example {
scroll-timeline-name: --side-scroller; /* must name the animation */
scroll-timeline-axis: x; /* triggers the animation on horiztonal scroll */
animation: swim; /* references a set of animation keyframes */
animation-timeline: --side-scroller; /* reference the timeline name */
}
```
--------------------------------
### CSS for padding-block-start Demonstration
Source: https://css-tricks.com/almanac/properties/p/padding/padding-block
CSS styles for demonstrating padding-block-start with various writing modes.
```css
body{
width:100%;
display:flex;
align-items:center;
flex-direction:column;
}
.title {
text-align:center;
font-size:20px;
}
.container {
display: flex;
align-items: flex-start;
flex-wrap: wrap;
gap: 1em;
margin: 2em;
}
.box {
width: 200px;
height: 200px;
}
.text {
border: 3px dashed #ff7a18;
padding-block-start: 40px;
}
.horizontal-tb {
writing-mode: horizontal-tb;
}
.vertical-rl {
writing-mode: vertical-rl;
}
.vertical-lr {
writing-mode: vertical-lr;
margin-left: -20px;
}
```
--------------------------------
### CSS justify-self: center start Example
Source: https://css-tricks.com/almanac/properties/j/justify-self
Aligns a grid item to the center along the block (column) axis and to the start along the inline (row) axis within its grid area. This demonstrates multi-axis alignment for a single item.
```css
.element { place-self: center start; }
```
--------------------------------
### Full CSS example with text-wrap-style: balance
Source: https://css-tricks.com/almanac/properties/t/text-wrap-style
A comprehensive CSS example demonstrating text-wrap-style: balance along with other styling for a demo.
```css
h1 {
text-align: center;
}
.balance h1 {
text-wrap-style: balance;
}
@layer demo {
* {
padding: 0px;
margin: 0px;
box-sizing: border-box;
}
html {
font-family: "Montserrat", sans-serif;
}
body {
display: flex;
justify-content: center;
height: 100dvh;
padding: 20px 20px 40px 20px;
}
main {
display: flex;
flex-flow: column;
align-items: center;
justify-content: space-around;
overflow: auto;
resize: horizontal;
border: 1px solid lch(from red l c h / 0.6);
padding: 0px 20px;
}
section {
display: flex;
flex-flow: column-reverse;
gap: 20px;
width: min(600px, 100%);
}
h1 {
border: 1px solid lch(from red l c h / 0.6);
}
p {
font-size: 1rem;
text-align: center;
}
}
```
--------------------------------
### padding-block-start CSS Example
Source: https://css-tricks.com/almanac/properties/p/padding/padding-block
Sets padding on the logical start edge of an element. The actual edge affected depends on the writing-mode.
```css
.element {
padding-block-start: 30px;
writing-mode: vertical-rl; /* Determines the padding block direction */
}
```
--------------------------------
### Complete example with grid areas
Source: https://css-tricks.com/almanac/properties/g/grid-column/grid-column-end
This example demonstrates how to set up a grid with named areas and position an `aside` element using `grid-column-end` to align with the `sidebar` area.
```html
```
```css
body {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-areas: "main main sidebar";
}
aside {
grid-column-end: sidebar-end;
}
```
--------------------------------
### CSS inset-inline-start Property Example
Source: https://css-tricks.com/almanac/properties/i/inset/inset-block
Illustrates the use of the inset-inline-start property to set the offset from the inline start edge of an element.
```css
.element { inset-inline-start: 80px; }
```
--------------------------------
### CSS inset-block-start Property Example
Source: https://css-tricks.com/almanac/properties/i/inset/inset-block
Illustrates the use of the inset-block-start property to set the offset from the block start edge of an element.
```css
.element {inset-block-start: 1.5rem; }
```
--------------------------------
### CSS for Basic Usage Demo with Progress()
Source: https://css-tricks.com/almanac/functions/p/progress
Full CSS for a demo using `progress()` to manage layout responsiveness. It maps a value (e.g., `1` in a `3, 2` range) to control element positioning and sizing.
```css
:root {
--test: calc(progress(1, 3, 2));
}
@layer demo {
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
main {
display: flex;
flex-flow: column;
gap: 1.6rem;
width: min(600px, 100%);
}
html {
font-family: "Lexend", sans-serif;
font-size: clamp(12px, min(3vh, 2.5vw), 18px);
color: #252525;
}
body {
height: 100dvh;
padding: 3rem;
}
h1 {
color: red;
font-size: 5rem;
}
img {
position: absolute;
top: 0;
right: 0;
z-index: -1;
height: 100%;
}
a {
color: currentColor;
}
}
```
--------------------------------
### CSS abs() with Plain Numbers
Source: https://css-tricks.com/almanac/functions/a/abs
Examples of using abs() with positive and negative plain numbers to get their absolute values.
```css
/* Plain Numbers */
abs(-4); /* returns 4 */
abs(16); /* returns 16 */
```
--------------------------------
### Full Example with @position-try and Anchor Positioning
Source: https://css-tricks.com/almanac/rules/p/position-try
A comprehensive example demonstrating the @position-try at-rule, anchor-name, position-anchor, and position-area properties to create adaptive positioning for elements.
```css
@position-try --compact-target {
height: 40px;
margin: 0px;
}
.anchor {
anchor-name: --my-anchor;
height: 80px;
aspect-ratio: 1;
}
.target {
position: absolute;
position-anchor: --my-anchor;
position-area: top;
position-try: --compact-target, flip-block;
width: 80px;
height: 100px;
margin: 20px;
}
body {
display: flex;
align-items: center;
justify-content: center;
height: 250vh;
}
/* Aesthetic Changes */
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body {
font-family: monospace;
}
.anchor {
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
background-color: #ffbd59;
}
.target {
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
background-color: #cb6ce6;
}
.not-supported {
position: fixed;
top: 0;
left: 0;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 40px;
font-weight: 600;
background-color: #ffbd59aa;
}
@supports (inset-area: top) {
.target {
inset-area: top;
}
}
@supports (position-area: top) or (inset-area: top) {
.not-supported {
display: none;
}
}
```
--------------------------------
### Set margin-inline-start with a percentage
Source: https://css-tricks.com/almanac/properties/m/margin/margin-inline-end
Use margin-inline-start to set the space on the logical start side of an element. This example uses a percentage value.
```css
.element { margin-inline-start: 25%; }
```
--------------------------------
### Full HTML Structure for Theming Example
Source: https://css-tricks.com/almanac/pseudo-selectors/h/has
The complete HTML for the theming example, including a container, select element, and multiple section elements.
```html
Title
Lorem ipsum dolor sit amet consectetur adipisicing elit. Magnam dolor ipsum porro ducimus perferendis esse ut ad sint laboriosam sapiente.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Magnam dolor ipsum porro ducimus perferendis esse ut ad sint laboriosam sapiente.
Title
Lorem ipsum dolor sit amet consectetur adipisicing elit. Magnam dolor ipsum porro ducimus perferendis esse ut ad sint laboriosam sapiente.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Magnam dolor ipsum porro ducimus perferendis esse ut ad sint laboriosam sapiente.
```
--------------------------------
### Equivalent Timing Functions: step-start and steps()
Source: https://css-tricks.com/almanac/properties/t/transition/transition-timing-function
Shows the equivalence between the 'step-start' keyword and the 'steps(1, start)' function.
```css
.example {
transition-timing-function: step-start;
}
.example-2 {
transition-timing-function: steps(1, start);
}
```
--------------------------------
### Equivalent to separate align-items and justify-items
Source: https://css-tricks.com/almanac/properties/p/place-items
This example shows the expanded form of the place-items: start center declaration, explicitly setting align-items and justify-items.
```css
.item {
display: grid;
align-items: start;
justify-items: center;
}
```
--------------------------------
### Complete CSS Example with path() and Layering
Source: https://css-tricks.com/almanac/properties/c/clip-path
A full CSS example demonstrating the path() function for clipping, along with CSS layering (@layer) for body styling.
```css
.hello {
width: 200px;
height: 200px;
background-color: aqua;
clip-path: path("M200 78c0 42-45 77-100 77-7 0-14 0-21-2l-44 47 12-57C18 129 0 104 0 78 0 35 45 0 100 0s100 35 100 78Z");
}
@layer base {
body {
display: grid;
height: 100dvh;
place-items: center;
}
}
```
--------------------------------
### Comprehensive CSS with border-image-outset
Source: https://css-tricks.com/almanac/properties/b/border-image/border-image-outset
This example showcases a full CSS setup for a container, including variables and the border-image-outset property with a unitless number value.
```css
:root {
--border-repeat: stretch;
--border-style: ridge;
--border-image-slice: 50;
--border-image-width: auto;
}
* {
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-wrap: wrap;
background-color: white;
}
section{
text-align: center;
display: flex;
width: 10rem;
background-color: lightblue;
flex-wrap: nowrap;
padding: 2rem;
height: 10rem;
align-items: center;
justify-content: center;
}
.container {
font-family: Georgia, 'Times New Roman', Times, serif;
border-image-source: url('https://img.freepik.com/free-vector/hand-drawn-abstract-background_23-2149957113.jpg?w=740&t=st=1671981151~exp=1671981751~hmac=ca672aa1441397c49c6a10c50f0b334af506c6250d3ef2e8849d75f89ae929b7');
border-image-slice: var(--border-image-slice);
border-image-repeat: var(--border-repeat);
border-width: 2rem;
border-image-width: var(--border-image-width);
border-color: grey;
border-style: var(--border-style);
transition: all 0.3s ease;
border-image-outset: 2;
}
```
--------------------------------
### Example CSS with View Timeline Axis
Source: https://css-tricks.com/almanac/properties/v/view-timeline-axis
This example shows a CSS setup for an animated element that uses a view timeline named '--flipping-yon-cards' driven by the horizontal axis. The animation 'flip-card' is controlled by the scroll progress within this timeline, with a specified range.
```css
width: 12em;
transform-style: preserve-3d;
border: 0.25em #ff00ff solid;
border-radius: 0.5em;
view-timeline-name: --flipping-yon-cards;
view-timeline-axis: x;
animation: flip-card;
animation-timeline: --flipping-yon-cards;
animation-range: 500px;
.back {
background-image: url("https://assets.codepen.io/1804713/cardback.svg");
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
backface-visibility: hidden;
border-radius: 0.5em;
}
.front {
background-color: #201020;
backface-visibility: hidden;
padding: 1em;
border-radius: 0.5em;
transform: rotateY(180deg);
}
```
--------------------------------
### Full Example with Color Override
Source: https://css-tricks.com/almanac/rules/f/font-palette-values
A complete example demonstrating @font-face, custom font palette with a color override, and basic page styling.
```css
@font-face {
font-family: Rocher;
src: url("https://res.cloudinary.com/ddzynrhrx/raw/upload/v1742600593/RocherColorGX_toea19.woff2")
format("woff2"),
url("https://res.cloudinary.com/ddzynrhrx/raw/upload/v1742600593/RocherColorGX_f0tfth.woff")
format("woff");
}
@font-palette-values --icepop {
font-family: Rocher;
base-palette: 3;
override-colors: 0 lch(31% 75 307);
}
h1 {
font-family: Rocher;
font-palette: --icepop;
}
@layer demo {
:root {
--rem-value: clamp(6px, 2vmin, 18px);
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html {
font-size: var(--rem-value);
}
body {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
height: 100dvh;
}
h1 {
text-align: center;
font-size: 5rem;
}
}
```
--------------------------------
### Placeholder Styling Example
Source: https://css-tricks.com/almanac/pseudo-selectors/p/placeholder
A basic example demonstrating the use of the ::placeholder pseudo-selector for styling placeholder text.
```css
::placeholder:read {}
:placeholder:write {}
```
--------------------------------
### Comprehensive Flexbox Alignment Example
Source: https://css-tricks.com/almanac/properties/a/align-self
A detailed example showcasing various align-self values ('start', 'center', 'end') within a flex container, including full styling for demonstration purposes. This snippet is suitable for creating interactive demos or understanding complex alignment scenarios.
```css
.container {
display: flex;
justify-content: space-between;
}
.item {
min-width: 160px;
min-height: 100px;
}
.item:nth-child(1) {
align-self: start;
}
.item:nth-child(2) {
align-self: center;
}
.item:nth-child(3) {
align-self: end;
}
@layer demo {
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html {
font-family: "Montserrat", sans-serif;
font-size: clamp(12px, 2.4vmin, 16px);
}
body {
display: flex;
flex-flow: column;
gap: 20px;
height: 100dvh;
padding: 20px;
}
.container {
gap: 20px;
height: min(260px, 100%);
list-style: none;
border: 1px solid black;
padding: 20px;
overflow: hidden;
background: repeating-linear-gradient(
120deg,
#ffbf0077 0px 20px,
transparent 20px 40px
);
background-clip: content-box;
}
.info {
display: flex;
gap: 6px;
.legend {
width: 20px;
height: 20px;
border: 1px solid black;
background: repeating-linear-gradient(
120deg,
#ffbf0077 0px 5px,
transparent 5px 10px
);
}
}
.item {
display: grid;
place-items: center;
border-radius: 10px;
corner-shape: squircle;
padding: 20px;
background-color: coral;
border: 3px solid #0005;
color: white;
font-weight: 600;
font-size: 1.4rem;
}
}
```
--------------------------------
### Positional Alignment Examples for place-content
Source: https://css-tricks.com/almanac/properties/p/place-content
Demonstrates various positional alignment value pairs for place-content, including center, start, end, flex-start, and flex-end.
```css
place-content: center start;
place-content: start center;
place-content: end left;
place-content: flex-start center;
place-content: flex-end center;
```
--------------------------------
### Examples of opacity() function arguments
Source: https://css-tricks.com/almanac/functions/o/opacity
Demonstrates various ways to use the opacity() function with numbers and percentages to control transparency, from fully opaque to fully transparent.
```css
/* fully opaque */
.element {
filter: opacity(1);
filter: opacity(100%);
/* transparency */
filter: opacity(0.2); /* 80% transparent */
filter: opacity(50%); /* 50% transparent */
/* Fully transparent */
filter: opacity(0);
filter: opacity(0%);
}
```
--------------------------------
### Move Command Example
Source: https://css-tricks.com/almanac/functions/p/path
The 'm' command moves the current point to a new location without drawing a line. This is useful for starting new sub-paths.
```css
m100,150
```
--------------------------------
### Complete CSS example with imports and styles
Source: https://css-tricks.com/almanac/rules/f/font-palette-values
A comprehensive CSS example including font imports, @font-palette-values definitions, element styling, and layout styles.
```css
@import url('https://fonts.googleapis.com/css2?family=Bungee+Spice&display=swap');
@font-face {
font-family: Honk;
src: url("https://res.cloudinary.com/ddzynrhrx/raw/upload/v1742601305/Honk-Color_aolcvq.ttf");
}
@font-palette-values --blue {
font-family: Bungee Spice;
override-colors: 0 lch(88% 91 144), 1 lch(72% 49 241);
}
@font-palette-values --blue {
font-family: Honk;
base-palette: 3;
override-colors: 0 lch(88% 91 144), 1 lch(72% 49 241);
}
h1 {
font-family: Honk;
font-palette: --blue;
}
h2 {
font-family: Bungee Spice;
font-palette: --blue;
}
@layer demo {
:root {
--rem-value: clamp(6px, 2vmin, 18px);
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html {
font-size: var(--rem-value);
}
body {
display: flex;
flex-flow: column;
align-items: center;
justify-content: center;
gap: 20px;
background-color: #000;
padding: 20px;
height: 100dvh;
}
h1 {
text-align: center;
font-size: 8rem;
}
}
```
--------------------------------
### hsl() with Relative Colors
Source: https://css-tricks.com/almanac/functions/h/hsl
Shows an example of using the hsl() function within the context of relative colors, starting from a base color like 'green'.
```css
.element {
color: hsl(from green, 50deg s 50%);
}
```
--------------------------------
### Full CSS for Button Example
Source: https://css-tricks.com/almanac/functions/o/oklch
Complete CSS for the button example, including layout, styling, and hover effects using OKLCH.
```css
* {
margin: 0;
padding: 0;
box-sixing: border-box;
}
.btn-container {
width: 100%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.button {
background-color: oklch(70% 0.15 240); /* Soft blue */
padding: 1rem 2rem;
text-align: center;
color: white;
font-family: Arial, sans-serif;
cursor: pointer;
transition: background-color 0.3s ease;
width: 200px;
}
.button:hover {
background-color: oklch(70% 0.15 280); /* Shift to purple */
}
```
--------------------------------
### CSS Brightness Syntax Examples
Source: https://css-tricks.com/almanac/functions/b/brightness
Demonstrates the syntax for the CSS brightness() function using percentages, numbers, and no arguments.
```css
/* Using percentages (0% to more than 100% range) */
filter: brightness(0%); /* a completely black element */
filter: brightness(50%); /* a partially dark element - 50% dimmed */
filter: brightness(100%); /* no change */
filter: brightness(150%); /* the element is 1.5 times brighter */
/* Using numbers (0 to more than 1 range) */
filter: brightness(0); /* a completely black element */
filter: brightness(0.5); /* a partially dark element - 50% dimmed */
filter: brightness(1); /* no change */
filter: brightness(1.5); /* the element is 1.5 times brighter */
/* Using no argument */
filter: brightness(); /* no change */
```
--------------------------------
### Comprehensive Keyframe and Animation Example
Source: https://css-tricks.com/almanac/rules/k/keyframes
A complete example demonstrating the definition of 'resize', 'reborder', and 'recolor' keyframes, their application to elements '#first' and '#second', and associated general styling for the demo.
```css
@keyframes resize {
from {
width: 25%;
}
to {
width: 50%;
}
}
@keyframes reborder {
from {
border-radius: 60% 40% 70% 30% / 30% 30% 70% 70%;
}
to {
border-radius: 60% 40% 33% 67% / 30% 45% 55% 70%;
}
}
@keyframes recolor {
from {
background-color: lch(77% 91 135);
}
to {
background: lch(77% 93 165);
}
}
#first {
animation: resize 1.5s infinite alternate, recolor 1.5s infinite alternate;
}
#second {
animation: resize 1.5s infinite alternate, reborder 1.5s infinite alternate;
}
@layer demo {
* {
padding: 0px;
margin: 0px;
}
body {
display: flex;
align-items: center;
justify-content: center;
gap: 40px;
padding: 0px 40px;
height: 100vh;
background: linear-gradient(to top, #c1dfc4 0%, #deecdd 100%);
}
.element {
max-width: calc(100vw - 30px);
max-height: min(500px, 90vmin);
aspect-ratio: 1;
border: 2px dashed grey;
background-color: white;
}
}
```
--------------------------------
### CSS Transition with Negative Delay Example
Source: https://css-tricks.com/almanac/properties/t/transition/transition-delay
Illustrates a transition with a negative delay, causing it to start immediately but partway through its duration, effectively cutting into the transition time.
```html
```
```css
.box {
width: 150px;
height: 150px;
background: goldenrod;
margin-top: 20px;
margin-left: auto;
margin-right: auto;
transition-delay: -1s;
}
.box:hover {
background-color: blue;
cursor: pointer;
}
.uni {
transition-duration: 3s;
transition-property: background-color;
}
```
--------------------------------
### Basic inset-inline-start Usage
Source: https://css-tricks.com/almanac/properties/i/inset/inset-inline-start
Demonstrates setting inset-inline-start with a fixed pixel value. Requires a positioned element to take effect.
```css
.element {
inset-inline-start: 50px;
position: relative; /* Apples to positioned elements */
writing-mode: vertical-rl; /* Determines the block start direction */
}
```
--------------------------------
### CSS Transition with Positive Delay Example
Source: https://css-tricks.com/almanac/properties/t/transition/transition-delay
Demonstrates a hover effect with a 2-second transition delay and a 1-second duration, showing the full delay before the transition starts.
```html
```
```css
.box {
width: 150px;
height: 150px;
background: goldenrod;
margin-top: 20px;
margin-left: auto;
margin-right: auto;
transition-delay: 2s;
}
.box:hover {
background-color: blue;
cursor: pointer;
}
.uni {
transition-duration: 1s;
transition-property: background-color;
}
```
--------------------------------
### calc-size() Basic Example
Source: https://css-tricks.com/almanac/functions/c/calc
A fundamental example of calc-size() using the 'auto' keyword as the basis for calculation.
```css
.element { width: calc-size(auto, size); }
```
--------------------------------
### CSS text-box-trim Example
Source: https://css-tricks.com/almanac/properties/t/text-box
Use `text-box-trim` to control whitespace trimming around text. The `trim-both` value trims whitespace from both the start and end of the text box.
```css
.element { text-box-trim: trim-both; }
```
--------------------------------
### Counter() Function Examples
Source: https://css-tricks.com/almanac/functions/c/counter
Demonstrates various ways to use the `counter()` function with different arguments, including outputting the count, adding prefixes/suffixes, and applying built-in counter styles.
```css
li::marker {
/* Outputting the Count */
content: counter(item); /* 1 */
/* Prefixing and Suffixing */
content: counter(item) "."; /* 1. */
content: "โซ " counter(item); /* โซ 1 */
content: "(" counter(item) ")"; /* (1) */
/* With Counter Styles */
content: counter(item, upper-roman); /* I. */
content: counter(item, lower-alpha) ")"; /* a.) */
content: counter(item, custom-counter-style) /* Custom Counter */;
}
```
--------------------------------
### Basic place-self Usage
Source: https://css-tricks.com/almanac/properties/p/place-self
Demonstrates the basic usage of place-self to align an element within its container. This example sets both align-self and justify-self to 'center' and 'start' respectively.
```css
.element {
place-self: center start;
}
```
--------------------------------
### Comprehensive CSS for :placeholder-shown Example
Source: https://css-tricks.com/almanac/pseudo-selectors/p/placeholder-shown
Includes general input styling along with the :placeholder-shown rule, and basic body/form styling for a complete visual example. This snippet combines general styles with the specific pseudo-class targeting.
```css
input {
font-size: 1.5rem;
margin: 10px;
padding: 10px;
width: 65%;
}
input:placeholder-shown {
border: 5px solid red;
}
html, body {
background: #333;
}
body {
padding-top: 4em;
}
form {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
```
--------------------------------
### justify-items in a grid container with justify-self override
Source: https://css-tricks.com/almanac/properties/j/justify-items
This example shows how justify-items is applied to a grid container to center its items, and how justify-self on a grid item can override this alignment to start.
```css
.grid {
display: grid;
justify-items: center;
}
.grid-item {
justify-self: start;
}
```
--------------------------------
### grid-area with two values (custom-ident for row start)
Source: https://css-tricks.com/almanac/properties/g/grid-area
This example uses the two-value syntax for grid-area with a custom identifier for grid-row-start. This sets both grid-row-start and grid-row-end to the custom identifier.
```css
/* */
.grid-item {
grid-area: area / 4;
/* is equivalent to */
grid-row-start: area;
grid-column-start: 4;
grid-row-end: area;
grid-column-end: auto;
}
```
--------------------------------
### Complete Example with Font Face and Styling
Source: https://css-tricks.com/almanac/rules/f/font-palette-values
A comprehensive CSS example including @font-face definition for a custom font, multiple @font-palette-values, keyframe animation, and basic body styling for a demo.
```css
@font-face {
font-family: Honk;
src: url("https://res.cloudinary.com/ddzynrhrx/raw/upload/v1742601305/Honk-Color_aolcvq.ttf");
}
@font-palette-values --neo {
font-family: Honk;
base-palette: 3;
}
@font-palette-values --rainbow {
font-family: Honk;
base-palette: 6;
}
@keyframes animate-palette {
from {
font-palette: --neo;
}
to {
font-palette: --rainbow;
}
}
h1 {
font-family: Honk;
font-palette: --neo;
animation: animate-palette 2s infinite alternate;
}
@layer demo {
:root {
--rem-value: clamp(6px, 2vmin, 18px);
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html {
font-size: var(--rem-value);
}
body {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
background-color: black;
padding: 20px;
height: 100dvh;
}
h1 {
text-align: center;
font-size: 8rem;
}
}
```
--------------------------------
### CSS box-sizing Demo
Source: https://css-tricks.com/almanac/properties/b/box-sizing
Demonstrates the visual differences between content-box, padding-box, and border-box models with example styling.
```html
```