MarkDownPad2爲html文件增加目錄

一、打開Html Head編輯器

依次打開   工具>選項>高級>html hrad編輯器

二、將下面的代碼粘貼進去

<!--bookmark -->
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://yandex.st/highlightjs/6.2/highlight.min.js"></script>


<script>hljs.initHighlightingOnLoad();</script>
<script type="text/javascript">
 $(document).ready(function(){

      $("h1,h2,h3,h4,h5,h6").each(function(i,item){
        var tag = $(item).get(0).localName;
        $(item).attr("id","wow"+i);
        $("#category").append('<a class="new'+tag+'" href="#wow'+i+'">'+$(this).text()+'</a></br>');
        $(".newh1").css("margin-left",0);
        $(".newh2").css("margin-left",20);
        $(".newh3").css("margin-left",40);
        $(".newh4").css("margin-left",60);
        $(".newh5").css("margin-left",80);
        $(".newh6").css("margin-left",100);
      });

       $(".book-body").html($(".book-body").nextAll())
 });
</script>
<style type="text/css">

@media (max-width: 1600px) {
    .book-body {
       padding-left:200px;
    }
}

@media (max-width: 1400px) {
    .book-body {
       padding-left:200px;
    }
}

@media (max-width: 1200px) {
    .book-body {
       padding-left:300px;
    }
}
@media (max-width: 700px) {
    .book-body {
       padding-left:0px;
    }
}
@media (min-width: 600px) {
    #category{
        position: fixed;
        left: 20px;
        top:0;
        height: 100%;
        overflow-y: scroll;
    }
}

@media (-webkit-max-device-pixel-ratio: 1) {
    ::-webkit-scrollbar-track-piece {
        background-color:#FFF
    }

    ::-webkit-scrollbar {
        width: 6px;
        height: 6px
    }

    ::-webkit-scrollbar-thumb {
        background-color: #c2c2c2;
        background-clip: padding-box;
        min-height: 28px
    }

    ::-webkit-scrollbar-thumb:hover {
        background-color: #A0A0A0
    }
}

</style>
<a href="javascript:scroll(0,0)" style="position:fixed;float:right;right:32px;top:70%;color:red">返回頂部</a> 
<div style="width:20%;" id="category" class="book-summary"></div>
<div class="book-body">
</div>

保存退出。

三、注意事項

實時預覽看不到效果,必須輸出爲HTML頁面以後才能看到效果。

四、感謝

這段代碼是在網上粘貼的,但是瀏覽器關閉的太快,找不到原出處了。感謝原作者。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章