confluence文檔添加右側浮動導航
confluence默認toc目錄是插入到文檔的固定位置的,很不方便。
所以我們通過幾行代碼讓它能夠右側浮動顯示。
首先需要插入目錄宏,
然后插入html宏,在里面添加如下內容:
<div id='my_toc' style="border:1px solid black;width: 350px;height:600px; overflow:auto; position: fixed; bottom: 20px;right: 25px; z-index: 100; background:url(http://sandbox.runjs.cn/uploads/rs/424/omg6xh6h/o_body_bg_new.jpg);"> </div>
<!-- <input type='button' id="btn1" value='把div1內容插入到div2' onclick='mv_div()'/> -->
<div style="border:1px solid black;width: 70px;height:30px; position: fixed; bottom: 20px;right: 25px; z-index: 110; text-align:center;line-height:30px; background-color:white;" onclick="toggle_toc()">
隱藏/顯示
</div>
<script>
function mv_div(){
var html = $('.toc-macro');
$('#my_toc').append(html);
};
$(mv_div)
function toggle_toc(){
if($("#my_toc").is(":hidden")){
$("#my_toc").show(); //如果元素為隱藏,則將它顯現
}else{
$("#my_toc").hide(); //如果元素為顯現,則將其隱藏
}
}
</script>
保存,ok。