Last active
June 7, 2017 19:40
-
-
Save mdschweda/3dbcb9052a344b0ed1603d182fa9f6a1 to your computer and use it in GitHub Desktop.
Stackedit TOC sidebar
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
.toc { | |
position: fixed; | |
left: 0; | |
top: 0; | |
bottom: 0; | |
padding: 2em 1em; | |
overflow-y: auto; | |
background: white; | |
} | |
.toc .toggle { | |
position: fixed; | |
padding: 0.4em 0.6em; | |
background: #3f3f3f; | |
border-radius: 4px; | |
box-shadow: 0px 0px 10px 8px rgba(255, 255, 255, 1); | |
color: #ddd; | |
text-decoration: none; | |
cursor: pointer; | |
-webkit-touch-callout: none; | |
-webkit-user-select: none; | |
-khtml-user-select: none; | |
-moz-user-select: none; | |
-ms-user-select: none; | |
user-select: none; | |
transition: background ease-in-out .15s, color ease-in-out .15s; | |
} | |
.toc .toggle:hover { | |
background: #313131; | |
color: #fff; | |
} | |
.toc ul { | |
padding-left: 1.25em; | |
font-size: 1.2em; | |
} | |
.toc > ul { | |
margin-top: 3em; | |
padding-left: 0; | |
} | |
.toc > ul > li > ul > li { | |
font-size: 0.75em; | |
} | |
.toc > ul > li > ul > li > ul > li { | |
font-size: 0.75em; | |
} | |
.toc.collapsed { | |
background: initial; | |
} | |
.toc.collapsed ul { | |
display: none; | |
} |
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
// Add <script src="toc.js"></script> at the end of exported .html | |
(function() { | |
var head = document.getElementsByTagName("head")[0]; | |
var link = document.createElement("link"); | |
link.rel = "stylesheet"; | |
link.href = "toc.css"; | |
head.appendChild(link); | |
var toc = document.getElementsByClassName("toc"); | |
if (toc.length == 1) { | |
var toggle = document.createElement("a"); | |
toggle.className = "toggle"; | |
toggle.addEventListener("click", function() { | |
if (toc[0].classList.contains("collapsed")) | |
toc[0].classList.remove("collapsed"); | |
else | |
toc[0].classList.add("collapsed"); | |
}) | |
toggle.innerHTML = '<i class="icon-menu"></i> Content'; | |
toc[0].insertBefore(toggle, toc[0].firstChild); | |
toc[0].classList.add("collapsed"); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment