markdown样式与脚本 编辑器

shuke 4月前 302

window.onload = function() {
    let body = document.getElementsByTagName("body")[0];
    body.style.width = innerWidth - 300 + "px";
    body.innerHTML += (`
<style>
#nav{position: fixed;
    width:250px;
    height: 100%;
     border-left:solid 1px silver;
    right: 0;line-height:1.4em;
    top: 0;overflow:auto;
    padding: 5px;}
    #nav .h1,#nav .h2,#nav .h3,#nav .h4,#nav .h5,#nav .h6{
    	font-size:1em;border:none;color:black;text-align:left;
    	display:block;    text-decoration: none;
    }
     #nav .h1{text-indent:0em}
     #nav .h2{text-indent:1em}
     #nav .h3{text-indent:2em}
     #nav .h4{text-indent:3em}
     #nav .h5{text-indent:4em}
     #nav .h6{text-indent:5em}
</style>
	<div id="nav" ></div>`)
    let arr = document.querySelectorAll("h1,h2,h3,h4,h5,h6");
    let str = "";
    arr.forEach((item, index) => {
        str += `<a class="${item.tagName}" href="#toc_${index}">├ ${item.innerText}</a>`
    })
    document.getElementById("nav").innerHTML = str;
}
body {
    background-color: #efefef;
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
    font-size: .8em;
    line-height: 1.7em;
    color: #24292e;
    font-family: 'Microsoft YaHei', Serif;
    word-wrap: break-word;
}
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote {
    margin: 0;
    padding: 0;
}
a {
    color: #0069d6;
}
a:hover {
    color: #005093;
    text-decoration: none;
}
a img {
    border: none;
}
img {
    width: auto;
    max-width: 100%;
    display: block;
}
img:after {
    content: "";
    display: block
}
p {
    margin: 1.7em 0;
    text-indent: 2em;
}
h1,
h2,
h3,
h4,
h5,
h6 {
    color: #333;
    line-height: 1.5em;
    margin: 0.3em 0;
    padding: 0.2em;
}
h1 {
    font-size: 34px;
    text-align: center;
    color: #218868;
    text-indent: 0;
    border-bottom: dotted 5px silver;
}
h2 {
    text-indent: .5em;
    font-size: 24px;
    border-left: #218868 solid 8px;
    border-bottom: solid 1px silver;
}
h3 {
    font-size: 18px;
    color: #218868; border-bottom: #218868 solid 2px;
    text-indent: 0.5em;
}
h4 {
    font-size: 16px;
    color: #117858;border-bottom: #218868 dashed 2px;
    text-indent: 1em;
}
h5 {
    font-size: 14px;
    color: #117858;border-bottom: #218868 dotted 1px; 
    text-indent: 2em;
}
h6 {
    font-size: 13px;
	color:#efefef;
    background-color: #117858;
    text-indent: 2em;
}
hr {
    margin: 0 0 19px;
    border: 0;
    border-bottom: 1px solid #ccc;
}
blockquote {
    border: solid 10px #cccccc;
    background: #f3f3f3;
    padding: 0;
    font-style: italic;
    border-radius: 5px;
}
blockquote p {
    font-size: 14px;
    line-height: 1.5em;
    margin: 0;
    font-style: italic;
    padding: .5em 1em;
    text-indent: 0;
    color: blue;
    background-color: #e4e4e4;
}
code,
pre {
    font-family: Monaco, Andale Mono, Courier New, monospace;
}
code {
    padding: 3px 10px;
    font-size: 14px;
    border-bottom: dotted #559966 1px
}
pre {
    display: block;
    padding: 0.2em 1em;
    background-color: #e4e4e4;
    font-size: 14px;
    border-left: 10px solid #cccccc;
    white-space: pre-wrap;
    word-wrap: break-word;
    background-image: url("data:image/gif;base64,R0lGODlhBQAeAPcDAAAAAP///yYmJgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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bW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M2IChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpBQjM5RkIzOTIxQzkxMUUzOEMwNUU0MjIwNTAyMTIxRiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpBQjM5RkIzQTIxQzkxMUUzOEMwNUU0MjIwNTAyMTIxRiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkFCMzlGQjM3MjFDOTExRTM4QzA1RTQyMjA1MDIxMjFGIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkFCMzlGQjM4MjFDOTExRTM4QzA1RTQyMjA1MDIxMjFGIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAQAAAwAsAAAAAAUAHgAACBgABwgcSLCgwYMIEypcyLChw4cQFwoQGBAAOw==")
}
pre code {
    border: none;
    font-family: Monaco, Andale Mono, Courier New, monospace;
    font-size: 14px;
    padding: 0;
    line-height: 30px;
    color: darkblue;
}
table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background: white;
    font-size: 14px;
    border-radius: 3px;
}
table th {
    border-bottom: 2px solid #ddd;
    vertical-align: bottom;
    padding: 8px;
    text-align: center;
}
table td {
    border-top: 1px solid #ddd;
    padding: 8px;
    vertical-align: top;
}
table>tbody>tr:nth-child(odd)>td,
.table>tbody>tr:nth-child(odd)>th {
    background-color: #f9f9f9;
}
table th,
table td {
    border: solid 1px #ddd;
}
table th {
    border-bottom: 2px solid #ddd;
}
table>tbody>tr:hover>td,
.table>tbody>tr:hover>th {
    background-color: #f5f5f5;
}
table th,
.table td {
    padding: 5px;
}


最新回复 (0)
全部楼主
返回