Skip to content

Instantly share code, notes, and snippets.

@pborenstein
Last active January 30, 2021 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pborenstein/12c787ab201e275a7449f602c95324b8 to your computer and use it in GitHub Desktop.
Save pborenstein/12c787ab201e275a7449f602c95324b8 to your computer and use it in GitHub Desktop.
Use Markdown lists to describe tables
/****
list-table
Make Markdown lists behave as a table.
https://www.pborenstein.com/articles/tablehacks/
Usage:
<div class="list-table extra" markdown="1">
- - **State**
- **Capital**
- **Size**
- - Texas
- Austin
- Medium
- - California
- Sacramento
- Medium
- - Illinois
- Springfield
- Medium
</div>
****/
div[class~="list-table"] > ul {
display: table;
list-style: none;
width: 100%;
margin: 1em 0;
padding: 0;
}
div[class~="list-table"] > ul > li {
display: table-row-group;
}
div[class~="list-table"] > ul > li:nth-child(even) {
background-color: #eee;
}
div[class~="list-table"] > ul > li:nth-child(odd) {
background-color: #fff;
}
div[class~="list-table"] > ul > li > ul {
display: table-row;
}
div[class~="list-table"] > ul > li > ul > li {
display: table-cell;
padding: 5px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment