Skip to content

Commit 89e2cc3

Browse files
committed
feat: use article in aside, multi-sidebar
you can use multiple articles in the aside element to allow for multiple containers in a sidebar. also, the second aside element will now appear on the right of the page
1 parent 3e38def commit 89e2cc3

File tree

2 files changed

+29
-35
lines changed

2 files changed

+29
-35
lines changed

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,27 @@ For your main content, or the actual content of the page, it is heavily recommen
9292

9393
### Sidebar
9494

95-
Optionally, you can add a sidebar to your page for pretty much anything you'd like. A good usage for this could be, for example, complex navigation on a docs website, where you wouldn't be able to fit it all into the header. The sidebar will sort normally with the rest of the content on smaller screens. To make a sidebar, place an `<aside>` tag. You must put it above the `<main>` content. Here's an example:
95+
Optionally, you can add a sidebar to your page for pretty much anything you'd like. A good usage for this could be, for example, complex navigation on a docs website, where you wouldn't be able to fit it all into the header. The sidebar will sort normally with the rest of the content on smaller screens. To make a sidebar, place an `<aside>` tag, and then put an `<article>` inside. You must put it above the `<main>` content. You can have up to two sidebars per page - the second one will appear on the right side. Here's an example:
9696

9797
```html
9898
<aside>
99-
<h1>Sidebar</h1>
100-
<nav>
101-
<ul>
102-
<li><a href="https://example.com">Page 1</a></li>
103-
<li>
104-
<a href="https://example.com">Page 2</a>
105-
<ul>
106-
<li><a href="https://example.com">Page 2.1</a></li>
107-
<li><a href="https://example.com">Page 2.2</a></li>
108-
</ul>
109-
</li>
110-
<li><a href="https://example.com">Page 3</a></li>
111-
<li><a href="https://example.com">Page 4</a></li>
112-
</ul>
113-
</nav>
99+
<article>
100+
<h1>Sidebar</h1>
101+
<nav>
102+
<ul>
103+
<li><a href="https://example.com">Page 1</a></li>
104+
<li>
105+
<a href="https://example.com">Page 2</a>
106+
<ul>
107+
<li><a href="https://example.com">Page 2.1</a></li>
108+
<li><a href="https://example.com">Page 2.2</a></li>
109+
</ul>
110+
</li>
111+
<li><a href="https://example.com">Page 3</a></li>
112+
<li><a href="https://example.com">Page 4</a></li>
113+
</ul>
114+
</nav>
115+
</article>
114116
</aside>
115117
```
116118

dev.css

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ h6 {
104104
address,
105105
area,
106106
article,
107-
aside,
108107
audio,
109108
blockquote,
110109
datalist,
@@ -270,33 +269,22 @@ footer nav ul li:not(:first-child)::before {
270269
}
271270

272271
main,
273-
aside {
272+
article {
274273
padding: 1.5rem;
275274
background: var(--dc-bg-1);
276275
border: 1px solid var(--dc-bg-3);
277276
border-radius: 0.25rem;
278277
}
279278

280-
article {
281-
padding: 1rem;
279+
main article {
282280
background: var(--dc-bg-2);
283-
border: 1px solid var(--dc-bg-3);
284-
border-radius: 0.375rem;
285281
}
286282

287-
article > *:last-child,
288-
aside > *:last-child,
289-
main > *:last-child {
283+
main > *:last-child,
284+
article > *:last-child {
290285
margin-bottom: 0;
291286
}
292287

293-
aside h1,
294-
aside h2,
295-
aside h3 {
296-
padding-bottom: 0;
297-
border-bottom: none;
298-
}
299-
300288
@media only screen and (max-width: 48rem) {
301289
main {
302290
margin: -1rem;
@@ -317,17 +305,21 @@ aside h3 {
317305
}
318306

319307
main,
320-
aside {
308+
article {
321309
padding: 1rem;
322310
}
323311
}
324312

325313
@media only screen and (min-width: 82rem) {
326314
aside {
327315
position: absolute;
328-
left: calc(50% - ((48rem) / 2) - (16rem));
329316
width: 16rem;
330-
overflow-y: auto;
317+
}
318+
aside:nth-child(even) {
319+
left: calc(50% - ((48rem) / 2) - (16rem));
320+
}
321+
aside:nth-child(odd) {
322+
right: calc(50% - ((48rem) / 2) - (16rem));
331323
}
332324
}
333325

0 commit comments

Comments
 (0)