样式说明展示
设最大高度,超出滚动条下拉,自动换行,一键复制,一键复制如果在代码包裹在隐藏块中,也照样能显示能使用。
以下是展示用的效果
function copyToClipboard(content) {
if (window.clipboardData) {
window.clipboardData.setData('text', content);
} else {
(function (content) {
document.oncopy = function (e) {
e.clipboardData.setData('text', content);
e.preventDefault();
document.oncopy = null;
}
})(content);
document.execCommand('Copy');
}
}
部署开始
下载附件中的single.js,替换b2/Assets/fontend/single.js
加入css
/*代码高亮美化开始*/
.entry-content pre:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 15px;
height: 15px;
border-radius: 50%;
background: #fc625d;
margin: 15px 25px;
}
.sticky-button {
position: -webkit-sticky;
position: sticky;
top: 0;
left:100%;
font-size:16px;
background: var(--b2color);
color: #fff;
border: none;
padding: 5px 10px;
border-radius: var(--b2radius);
cursor: pointer;
}
.entry-content pre {
position: relative;
border-radius: 6px;
padding-top: 50px;
box-shadow: 0px 8px 20px -10px #000;
}
.entry-content pre code, .content-show-roles pre code{
white-space: pre-wrap!important;
}
.entry-content pre {
min-height:100px;
max-height:300px;
overflow-y: auto; /* 当内容高度超出元素高度时显示滚动条 */
overflow-x: auto; /* 隐藏水平滚动条 */
}
.entry-content pre:before {
content: '';
position: absolute;
top: 0;
left: 25px;
width: 15px;
height: 15px;
border-radius: 50%;
margin: 15px 25px;
background: #fdbc40;
}
ol.linenums:after {
content: '';
position: absolute;
top: 0;
left: 50px;
width: 15px;
height: 15px;
border-radius: 50%;
margin: 15px 25px;
background: #35cd4b;
}
/*代码高亮美化结束*/