Last active
January 30, 2021 18:00
-
-
Save pborenstein/12c787ab201e275a7449f602c95324b8 to your computer and use it in GitHub Desktop.
Use Markdown lists to describe tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**** | |
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