Created
July 27, 2016 23:11
-
-
Save pbakaus/af4effedc249f280614490c563beaef9 to your computer and use it in GitHub Desktop.
Flexbox freebie: Auto-growing list (for AMP Roadmap)
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
.steps { | |
... | |
/* enable flex, wrap all items. | |
* - align-items' and align-content's default are set to 'stretch', | |
* so li's automatically evenly distributed and stretched | |
*/ | |
display: flex; | |
flex-wrap: wrap; | |
.... | |
/* alternative to built-in list style that we can style */ | |
list-style-type: none; | |
counter-reset: steps; | |
} | |
/* the steps (li) */ | |
.steps > li { | |
... | |
/* gives items an explicit width, so we do things like | |
* like ellipsis in overflowing text.. | |
*/ | |
flex: 1 1 100%; | |
... | |
border-left: 3px solid; | |
counter-increment: steps; | |
} | |
/* the smallish description label next to the bubble */ | |
.steps > li::before { | |
/* show number + description from attribute in heading */ | |
content: "Step " counter(steps) ": " attr(data-description); | |
... | |
} | |
/* the bubble with the number in it */ | |
.steps > li::after { | |
... | |
/* show the number from the counter in the pseudo element */ | |
content: counter(steps); | |
} |
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
<ol class="steps"> | |
<li data-description="Step 1 description"> | |
<ul> | |
<li>Substep 1</li> | |
<li>Substep 2</li> | |
<li>Substep 3</li> | |
</ul> | |
</li> | |
<li data-description="Step 2 description"> | |
<ul> | |
<li>Substep 1</li> | |
<li>Substep 2</li> | |
</ul> | |
</li> | |
</ol> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment