Basic Usage
shell-grid
uses CSS Grid to create a layout with four elements: header
, left-sidebar
, content
, and right-sidebar
.
<div class="shell-grid"> <header>Header</header> <aside class="left-sidebar">Left Sidebar</aside> <main class="content">Content</main> <aside class="right-sidebar">Right Sidebar</aside></div>
Content
Optional Header and Right Sidebar
The header
and right-sidebar
are optional, while left-sidebar
and content
are required.
<div class="shell-grid"> <aside class="left-sidebar">Left Sidebar</aside> <main class="content">Content</main></div>
Content
Adjusting Content and Sidebar Widths
You can modify the widths of content
, left-sidebar
, and right-sidebar
using CSS variables. The default values are as follows:
:root { --content-width: 1fr; --lsb-width: auto; --rsb-width: auto;}
Content
Sticky Sidebar within Content
To create a sticky sidebar within content
(like the one on this page), create a grid
within content
and use sticky
for the sidebar.
<div class="shell-grid"> <aside class="left-sidebar"> ... </aside> <div class="content"> <div class="grid-simple [--cols:2]"> <main>Content</main> <aside class="sticky">Sticky Sidebar</aside> </div> </div></div>
Paragraph 1
Paragraph 2
Paragraph 3
Paragraph 4
Paragraph 5
Paragraph 6
Paragraph 7
Paragraph 8
Paragraph 9
Paragraph 10
Paragraph 11
Paragraph 12
Paragraph 13
Paragraph 14
Paragraph 15
Paragraph 16
Paragraph 17
Paragraph 18
Paragraph 19
Paragraph 20
Sticky Sidebar