Skip to content

Commit 6b024b7

Browse files
ctruedenmattxwang
authored andcommitted
Make tables 100% width again
But document how to present tables in other ways, too. Closes #130.
1 parent 2d42259 commit 6b024b7

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

_pages/editing/tables.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,55 @@ You can, however, easily create one using Markdown:
1919
{% endcapture %}
2020
{% include editing/example code=simple-table %}
2121

22+
## Aligning Tables
23+
24+
By default, tables are stretched to 100% width:
25+
26+
| Blue | Red | Green | Yellow | Purple |
27+
|------|-----|-------|--------|--------|
28+
| 5 | 4 | 3 | 2 | 1 |
29+
| 1 | 2 | 3 | 4 | 5 |
30+
31+
If you want the table to be its natural width instead, put `{:.left}` beneath the table:
32+
33+
**Code**
34+
35+
```
36+
| Blue | Red | Green | Yellow | Purple |
37+
|------|-----|-------|--------|--------|
38+
| 5 | 4 | 3 | 2 | 1 |
39+
| 1 | 2 | 3 | 4 | 5 |
40+
{:.left}
41+
```
42+
43+
**Result**
44+
45+
| Blue | Red | Green | Yellow | Purple |
46+
|------|-----|-------|--------|--------|
47+
| 5 | 4 | 3 | 2 | 1 |
48+
| 1 | 2 | 3 | 4 | 5 |
49+
{:.left}
50+
51+
Or for a centered table, use `{:.center}`:
52+
53+
**Code**
54+
55+
```
56+
| Blue | Red | Green | Yellow | Purple |
57+
|------|-----|-------|--------|--------|
58+
| 5 | 4 | 3 | 2 | 1 |
59+
| 1 | 2 | 3 | 4 | 5 |
60+
{:.center}
61+
```
62+
63+
**Result**
64+
65+
| Blue | Red | Green | Yellow | Purple |
66+
|------|-----|-------|--------|--------|
67+
| 5 | 4 | 3 | 2 | 1 |
68+
| 1 | 2 | 3 | 4 | 5 |
69+
{:.center}
70+
2271
## Aligning Columns
2372

2473
You can place `:` symbols in the table header to specify column alignment:

assets/css/main.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ blockquote:before, blockquote:after, q:before, q:after {
5050
table {
5151
border-collapse: collapse;
5252
border-spacing: 0;
53+
width: 100%;
5354
}
5455

5556
body {
@@ -1616,12 +1617,10 @@ ul.major-icons li .icon {
16161617
.left {
16171618
margin-left: 0;
16181619
margin-right: 1em;
1619-
text-align: left;
16201620
}
16211621
.right {
16221622
margin-left: 1em;
16231623
margin-right: 0;
1624-
text-align: right;
16251624
}
16261625
.center {
16271626
display: block;
@@ -1633,6 +1632,11 @@ ul.major-icons li .icon {
16331632
width: 100%
16341633
}
16351634

1635+
table.center, table.left, table.right {
1636+
width: auto;
1637+
display: table;
1638+
}
1639+
16361640
.float-left {
16371641
margin-right: 1em;
16381642
}

0 commit comments

Comments
 (0)