记录一些博客的编写技巧
折叠代码段
在md头中添加设置
1 2 3
| article: highlight: fold: folded
|
eg:
图片并列排版
在页面模板themes > icarus > source > css > custom.styl
中添加以下代码:
1 2 3 4 5 6 7 8 9
| .same-height { max-height: 5000px; width: auto; object-fit: contain; margin-right: 20px; } .same-height:last-child { margin-right: 0; }
|
默认为同一排中的图片尽量大,尽量密排列
若想针对某页单独更改图片排版,在页面中加入以下代码
1 2 3 4 5 6 7 8
| <style> .same-height { max-height: 5000px; width: auto; object-fit: contain; margin-right: 20px; } </style>
|
在用户代码段中添加以下代码:
同时,设置markdown自动补齐(editor.tabCompletion
)为on:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| "Image Container": { "prefix": "img_mutiple", "body": [ "<div style=\"display: flex; justify-content: center; align-items: center;\">", " <img class=\"same-height\" src=\"$1\" alt=\"\">", " <img class=\"same-height\" src=\"$2\" alt=\"\">", "</div>", "" ], "description": "Insert an image container with two images and CSS for same height." }, "Image single": { "prefix": "img_single", "body": [ "<div style=\"display: flex; justify-content: center; \">", " <img style=\"max-height: 300px; width: auto; object-fit: contain; margin-right: 20px;\" src=\"$1\" alt=\"\">", "</div>", "" ], "description": "Insert an image container with two images and CSS for same height." }
|
在setting.json中插入以启用代码段预览:
1 2 3 4 5 6 7
| "[markdown]":{ "editor.quickSuggestions": { "other": "on", "comments": "on", "strings": "on" } },
|
在添加图片时,使用img
补全,或在以下代码中插入链接
1 2 3 4 5 6 7 8 9 10 11
| <div style="display: flex; justify-content: center; align-items: center;"> <img class="same-height" src="" alt=""> <img class="same-height" src="" alt=""> </div>
<div style="display: flex; justify-content: center; align-items: center;"> <img style="max-height: 300px; width: auto; object-fit: contain; margin-right: 20px;" src="" alt=""> </div>
|
justify-content 为水平方向对齐 ,align-items为竖直方向对齐
置顶
top
值越大,越靠前