Created
July 7, 2015 23:56
-
-
Save natejacobson/a8b9aaa849b370b54326 to your computer and use it in GitHub Desktop.
Simple Datalist Accordion
This file contains 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
<script>$('.folded dt').click( function() { $(this).toggleClass('unfolded').next('dd').toggleClass('unfolded'); });</script> | |
<style> | |
.folded dt, | |
.folded dd { | |
display: block; | |
} | |
.folded dt { | |
font-size: 1.2rem; | |
padding: .5rem 0; | |
font-weight: 300; | |
} | |
.folded dt:nth-of-type(odd) | |
.folded dt:nth-of-type(odd) + dd { | |
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ffffff+0,ffffff+50,ffffff+100&0+0,1+50,0+100 */ | |
background: -moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 50%, rgba(255,255,255,0) 100%); /* FF3.6+ */ | |
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(255,255,255,0)), color-stop(50%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,0))); /* Chrome,Safari4+ */ | |
background: -webkit-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 50%,rgba(255,255,255,0) 100%); /* Chrome10+,Safari5.1+ */ | |
background: -o-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 50%,rgba(255,255,255,0) 100%); /* Opera 11.10+ */ | |
background: -ms-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 50%,rgba(255,255,255,0) 100%); /* IE10+ */ | |
background: linear-gradient(to right, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 50%,rgba(255,255,255,0) 100%); /* W3C */ | |
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 */ | |
} | |
.folded dt:not(.unfolded):nth-of-type(even), | |
.folded dt:not(.unfolded):nth-of-type(even) + dd { | |
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ffffff+0,eaeaea+50,ffffff+100&0+0,1+50,0+100 */ | |
background: -moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(234,234,234,1) 50%, rgba(255,255,255,0) 100%); /* FF3.6+ */ | |
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(255,255,255,0)), color-stop(50%,rgba(234,234,234,1)), color-stop(100%,rgba(255,255,255,0))); /* Chrome,Safari4+ */ | |
background: -webkit-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(234,234,234,1) 50%,rgba(255,255,255,0) 100%); /* Chrome10+,Safari5.1+ */ | |
background: -o-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(234,234,234,1) 50%,rgba(255,255,255,0) 100%); /* Opera 11.10+ */ | |
background: -ms-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(234,234,234,1) 50%,rgba(255,255,255,0) 100%); /* IE10+ */ | |
background: linear-gradient(to right, rgba(255,255,255,0) 0%,rgba(234,234,234,1) 50%,rgba(255,255,255,0) 100%); /* W3C */ | |
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 */ | |
} | |
.folded dt { | |
border-top: 1px transparent solid; | |
} | |
.folded dd { | |
display: none; | |
} | |
.folded dt.unfolded, | |
.folded dd.unfolded { | |
color: black; | |
} | |
.folded dt.unfolded { | |
border-top: 1px $gray solid; | |
padding-top: 1rem; | |
padding-bottom: .25rem; | |
} | |
.folded dt.unfolded + dd { | |
border-bottom: 1px rgba(0, 0, 0, 0.1) solid; | |
} | |
.folded dd { | |
opacity: .5; | |
transition: opacity .5s ease-in; | |
} | |
.folded dd.unfolded { | |
display: block; | |
padding-bottom: 1rem; | |
opacity: 1; | |
} | |
.folded dt:hover { | |
cursor: pointer; | |
color: black; | |
} | |
</style> | |
<dl> | |
<dt>List Item Title and Toggle</dt> | |
<dd>Content hidden until toggled</ddi> | |
</dl> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment