Using .breakout-item and .breakout-item-max helpers
Breakout layout
The .breakout layout allows images, tables, and other figures to automatically extend or bleed beyond their parent container’s width.
Demo
Break out a wide image from the text flow:
Or table:
| Imagine |
a |
really |
wide |
table |
here |
|---|---|---|---|---|---|
| ... |
Or code block:
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quod. Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quod.</p>
Or anything else:
.breakout-all also visually breaks out headings and horizontal rules:
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
How it works
.breakout,
.breakout-all {
/* Prepare the container for breakout elements */
padding-inline: 10%;
max-width: calc(10% + 65ch + 10%);
/* Breakout direct children only */
& > * {
&:is(
table,
pre,
figure, video, iframe, canvas,
img, picture,
/* Custom utility classes for other tags that need to be broken out */
.breakout-item,
.breakout-item-max
) {
width: fit-content;
min-width: 100%;
max-width: 125%;
margin-left: 50%;
transform: translateX(-50%);
}
/* Respect img/picture min-width */
&:is(img, picture) {
min-width: auto;
}
/* Max out the width of the element */
&.breakout-item-max {
width: 125% !important; /* !important is for cases like figure.breakout-item-max @TODO */
}
}
}
.breakout-all > * {
&:is(h2, h3, h4, h5, h6, hr):not([class]) {
position: relative;
&::before {
content: "";
display: block;
position: absolute;
background: gray;
opacity: 12.5%;
}
}
&:is(h2, h3, h4, h5, h6):not([class]) {
&::before {
width: 10em;
right: 100%;
margin-right: 0.8ch;
height: 0.25em;
top: 50%;
transform: translateY(-50%);
background: linear-gradient(to left, gray, transparent);
}
/* @TODO: add to tricks-wiki why `*` works here, but `&` fails */
&:where(hr + *) {
&::before {
display: none !important;
}
}
}
&:is(hr) {
height: 0.5rem;
border: none;
overflow: visible;
&::before {
width: 100vw;
left: 50%;
height: 100%;
transform: translateX(-50%);
}
}
}
Install
Via CDN
<link rel="stylesheet" href="
https://cdn.jsdelivr.net/npm/@anyblades/blades@^0.28.0-alpha/assets/breakout.min.css
">
Prepackaged
- Blades:
/anyblades/blades
- Pico:
/anyblades/pico