首页 > 其他分享 >Less is richness,基于less is more的博客园宽屏主题魔改

Less is richness,基于less is more的博客园宽屏主题魔改

时间:2024-08-12 15:05:33浏览次数:5  
标签:less color 博客园 魔改 important background 10px 0px margin

写在前面

之前做过很多个人博客,都是做着玩的,资源托管在免费或低价的服务器上,也不经常维护,所以就一直不长久,最终还是选择了博客园。发现博客园可以自定义样式,于是试着给博客换了一个又一个主题。个人比较喜欢宽屏的样式,感觉LessIsMore主题布局比较好、也比较简洁,但是不够美观,打算对此进行魔改。

经过两天的F12+参考知乎掘金等网站+问豆包+调试,终于大功告成。

主题名字叫less is more,这是建筑师路德维希·密斯·凡德罗说过的一句话,意思是简单的东西往往带给人们的是更多的享受。魔改之后,就叫LessIsRichness吧。

魔改的设置(需要先申请js权限)

侧边公告栏

<div class="blog-news-main" style="margin-top: 5px;">
公告内容
</div>
<div id="sidebar_about" class="sidebar-block"><div class="catListTag">
    <h3 class="catListTitle"><a href="https://www.cnblogs.com/xiins/tag/" class="sidebar-card-title-a">关于我</a></h3>
</div>
</div>

<div id="profile_avatar">
<a href="https://www.cnblogs.com/xiins">
<img src="https://pic.cnblogs.com/avatar/3501016/20240810101545.png" alt="Shu-How Z" 
class="img_avatar" width="85px" height="85px" style="border-radius:100%">
</a>
</div>

css代码

body {font-family: -apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,Helvetica,Segoe UI,Arial,PingFang SC,miui,Hiragino Sans GB,Microsoft Yahei,sans-serif; 
    font-size: 14px !important; margin-top: 0px;
    color: #252933;
    background-color: rgb(244,246,249);}
    
    a,dt,dd{
        color: #252933;
        transition: background-color 0.25s ease;
        transition: color 0.25s ease;
        text-decoration: none!important;
    }
    a:hover,dt:hover,dd:hover,#sideBarTab h2:hover {
        color: #007fff;
        transition: background-color 0.25s ease;
        transition: color 0.25s ease;
    }
    
    #cnblogs_post_body h1 {
        font-size: 22px;
    }
    #cnblogs_post_body h2 {
        font-size: 20px;
    }
    h1, h2, h3, h4, h5, h6, th {
        color: #252933;
        transition: color 0.25s ease;
    }
    h1:hover, h2:hover, h3:hover, h4:hover, h5:hover, h6:hover, th:hover {
        color: #007fff;
        transition: color 0.25s ease;
    }

    code {
        font-size: 14px!important;
        border-radius: 5px!important;
        margin: 5px 0px 5px 0px!important;
    }
    
    #green_channel a {
        background: url() repeat-x;
        display: inline-block;
        padding: 3px 8px;
        color: #fff;
        text-decoration: none;
        font-weight: bold;
        cursor: pointer;
        margin-right: 10px;
        border-radius: 5px;
        -webkit-border-radius: 10px;
        box-shadow: 0 0px 0px rgba(0, 0, 0, .5);
        text-shadow: 0 -1px 1px rgba(0,0,0,.25);
        vertical-align: middle;
    }
    #main {
        margin: 20px;
    }
    
    #mainContent {
        background-color: rgb(255,255,255);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); 
        padding: 10px 0px 10px 0px;
    }
    #sideBar {
        background-color: rgb(255,255,255);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); 
        top: 70px;
        border: 0px;
        width: 260px;
        right: 17px;
        padding: 0 30px 20px 30px;
    }
    /*标题*/
    #blogTitle {
        display: flex;
        align-items: center;
        position: absolute;
        top: 5px;  /* 您可以根据实际需要调整这个值来控制标题距离导航的距离 */
        left: 20px;
        padding: 0px;
    }
    #Header1_HeaderTitle {
        background-color: #f2f3f5;
        border-radius: 25px;
        padding: 0px 20px 0px 20px;
        color: #007fff !important;
        font-family: 'Courier New', Courier, monospace;
        font-weight: 600;
    }
    
    #Header1_HeaderTitle:hover {
        color: #fff !important;
        background-color: #007fff;
    }
    
    .subtitle {
        margin: 5px 0px 0px 10px;
    }
    
    /*导航*/
    
    #navigator {
        background-color: #fff;
        border-top: 1px solid #ccc;
        border-bottom: 1px solid #ccc;
        border-width: 1px;
        height: 50px;
        line-height: 50px;
        color: #8a919f;
        padding-left: 250px;
        padding-right: 70px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); 
        border: 0px;
    
    }
    
    #navList li a {
        font-size: 15px!important;
        color: #8a919f;
        border-radius: 5px;
        padding: 7px 10px 7px 10px;
        margin: 0px;
        transition: color 0.5s ease!important;
    }
    
    #navList li a:hover {
        color: #007fff;
        transition: color 0.5s ease!important;
    }
    
    #navList li + li:before {
        content: "|";  /* 竖线内容 */
        margin-right: 20px;  /* 20 像素的右外边距 */
        color: #8a919f;  /* 竖线颜色为黑色 */
    }
    
    #stats_post_count,#stats_article_count,#stats_comment_count,#stats_total_view_count{
        margin-left: 10px;
    }
    
    
    /*日期归档*/
    .dayTitle {
        margin: 10px 0px 10px 30px;
    }
    .dayTitle a {
        color: #333;
        background-color: #f2f3f5;
        border-radius: 10px;
        padding: 5px 20px 5px 20px;

    }

    .dayTitle a:hover {
        background-color: #eaf5ff;
        color: #007fff;
    }
    
    /*首页左侧*/
    .postBody {
        color: #252933!important;
        font-size: 14px;}
    
    .forFlow {
        margin: 15px 30px 15px 30px;
    }

    .article-wrapper a.postTitle2.vertical-middle span {
        color: #252933!important;
        font-size: 18px!important;
        font-weight: 600!important;}

        .article-wrapper a.postTitle2.vertical-middle span:hover {
        color: #007fff!important;
    }
    
    #cb_post_title_url > span {
        color: #252933!important;
        font-size: 26px!important;
        font-weight: 600!important;}

    #cb_post_title_url > span:hover {
        color: #007fff!important;
    }

    .day img{
        border-radius: 5px;
    }
    
    
    .postDesc{
        color: #8a919f;
        transition: background-color 0.25s ease!important;
        padding-bottom: 0px;
    }
    .postDesc a{
        color: #fff !important;
        background-color: #bbb;
        border-radius: 3px;
        padding: 2px 10px 2px 10px;
        margin-left: 5px;
        transition: background-color 0.25s ease!important;
    }
    .postDesc a:hover{
        background-color: #8a919f;
    }
    
    .c_b_p_desc{
        color: #8a919f;
        line-height: 2;
        font-size: 14px;
        margin: 10px 0px 10px 0px;
    }
    
    .post-view-count,
    .post-comment-count,
    .post-digg-count
    {
        color: #8a919f;
        background-color: #f2f3f5;
        border-radius: 3px;
        padding: 2px 10px 2px 10px;
        margin-left: 5px;
    }

    .article-wrapper{
        padding: 15px 30px 15px 30px;
        font-size: 12px;
        color:#8a919f;
    }
    .article-wrapper:hover{
        background-color: rgb(247,248,250);
    }
    
    .PostListTitle, .entrylistTitle, .thumbTitle, .forFlow h3 div, .galleryTitle {
        font-size: 18px;
        font-weight: bold;
        margin: 0px 0px 10px 0px;
        text-align: left;
    }

    .postTitle{
        margin: 0px 0 0px;
    }
    .article-wrapper a[rel="nofollow"] {
        display: none;
    }


    /*内容页*/

    .author_avatar {border-radius: 100%;}
    .author_profile_info {margin: 10px 0px 0px 10px}
    #author_profile {
        width: 180px;
    }
    
    /*评论*/
    .comment_textarea {
        margin-top: 10px!important;
    }
    
    
    .comment_textarea{
        width: 100% !important;
    }
    
    .comment_digg,.comment_bury  {
        color: #333;
        background-color: #f2f3f5;
        border-radius: 10px;
        padding: 5px 5px 5px 5px;
    }
    
    .comment_digg:hover {
        background-color: #eaf5ff;
        color: #007fff;
    }
    .comment_bury:hover {
        background-color: rgb(223, 240, 255);
        color: #0040ff;
    }
    
    #div_digg .buryit, #div_digg .diggit {
        border-radius: 6px;
        cursor: pointer;
        height: 58px;
        margin: 0;
        padding-top: 0;
        text-align: center;
        width: 58px;
    }
    
    #div_digg .diggit {
        background: #ecfdf5;
        border: 1px solid #a7f3d0;
        color: #10b981;
        float: left;
    }
    #div_digg .diggit:hover {
        background: #a7f3d0;
        border: 1px solid #a7f3d0;
    }
    #div_digg .buryit {
        background: #f6f8fa;
        border: 1px solid #e5e7eb;
        color: #6b7280;
        float: right;
    }
    #div_digg .buryit:hover {
        background: #e5e7eb;
        border: 1px solid #e5e7eb;
    }
    
    #div_digg .diggit .diggnum {
        color: #10b981;
        font-size: 16px;
    }
    #div_digg .diggnum {
        line-height: 1.5em !important;
    }
    
    #div_digg .buryit .burynum {
        color: #6b7280;
        font-size: 16px;
    }
    #div_digg .burynum {
        line-height: 1.5em !important;
    }
    
    #digg_count:before {
        content: "▲";  /* 清空默认内容 */
        font-size: 18px;
        color: #10b981;
        display: block;
        margin: 5px 0px 2px 0px;
    }
    #bury_count:before {
        content: "▼";  /* 清空默认内容 */
        font-size: 18px;
        color: #6b7280;
        display: block;
        margin: 5px 0px 2px 0px;
    }
    
    
    .layer{
        color: #007fff;
        background-color: #eaf5ff;
        border-radius: 3px;
        padding: 2px 10px 2px 10px;
        margin-right: 10px;
        border: 1px solid #007fff;
    }
    .layer:hover{
        color: #fff;
        background-color: #007fff;
    }
    
    .feedbackCon{
        margin-top: 5px;
    }
    
    .comment_btn{
        color: #007fff;
        background-color: #eaf5ff;
        border-radius: 3px;
        padding: 5px 15px 5px 15px;
        margin-right: 10px;
        border: 1px solid #007fff;
        width:120px;
        height:32px;
    }
    .comment_btn:hover{
        color: #fff;
        background-color: #007fff;
    }
    
    .comment-nav-right a{
        color: #fff !important;
        background-color: #bbb;
        border-radius: 3px;
        padding: 2px 10px 2px 10px;
        margin-left: 5px;
    }
    .comment-nav-right a:hover{
        background-color: #8a919f;
    }
    
    /*摘要*/
    a[class="c_b_p_desc_readmore"] {
        background-color: rgb(255, 255, 255);  /* 初始背景色 */
        padding: 2px 15px 2px 15px;  /* 内边距,增加点击区域和美观度 */
        border-radius: 20px;  /* 圆角 */
        color: #007fff !important;  /* 文字颜色 */
        margin: 0px 0px 0px 5px;
        text-decoration: none !important;
        border: 1px solid #007fff;  
        transition: background-color 0.25s ease;
        transition: color 0.25s ease;
    }
    
    a[class="c_b_p_desc_readmore"]:hover {
        background-color: #eaf5ff;  /* 悬停时的背景色 */
        color: #007fff !important;  /* 悬停时的文字颜色 */
        border-color: #007fff !important;
        transition: background-color 0.25s ease;
        transition: color 0.25s ease;
    }
    
    /*底部*/
    #footer {
        color:#666;
        background-color: #fff;
        padding: 10px 10px 10px 10px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); 
    }

    
    /*侧栏*/
    .catListTitle {
        color: #666;
        font-size: 16px !important;
        line-height: 22px !important;
        font-weight: normal !important;
    }
    .blog-news-main +#sidebar_about,
    .sidebar-block +.sidebar-block,
    .sidebar-block +#sidebar_categories,
    .catListPostCategory +.catListPostArchive,
    #sideBarMain +#uprightsideBar
    {
        border-top: 1px dashed rgba(0, 0, 0, 0.2);
        margin-top: 10px;  /* 横线与上方元素之间的间距 */
    }
    .catListTitle:before,#sideBarTab h2:before {
        content: "■";  /* 清空默认内容 */
        color: #007fff;
        display: inline-block;
        margin-right: 10px;  /* 图标与文字之间的间距 */
    }
    
    .catListTitle a[href="https://www.cnblogs.com/xiins/post-categories"] {
        margin-left: -4px;
    }
    .catListTitle a[href="https://www.cnblogs.com/xiins/post-categories"] {
        margin-left: -4px;
    }
    
    .catListPostArchive h3.catListTitle {
        margin-left: -4px;
    }
    
    #sideBarTab h2 {
        font-size: 16px!important;
        font-weight: normal!important;
        color: #666;
        line-height: 22px !important;
    }
    
    #sideBarTab {
        margin-top: 10px;
    }
    
    #sideBarContents dd, dt {
        cursor: pointer;
    }
    #sideBarContents dd{
        margin-left:20px;
    }
    #sideBarContents dd.indent3{
        margin-left:40px;
    }
    #sideBarContents dd.indent4{
        margin-left:60px;
    }
    #sideBarContents dd.indent5{
        margin-left:80px;
    }
    #sideBarContents dd.indent6{
        margin-left:100px;
    }
    
    #sidebar_toptags ul,#sidebar_categories ul {
        margin: 5px 0px 5px 0px;
    }
    
    #sidebar_toptags ul li a,#sidebar_categories ul li a {
        color: #007fff!important;
        background-color: #eaf5ff;
        border: 1px solid #007fff;
        border-radius: 3px;
        padding: 2px 10px 2px 10px;
        margin: 0px 0px 0px 5px;
        transition: background-color 0.25s ease;
        transition: color 0.25s ease;
    }
    
    #sidebar_toptags ul li a:hover,#sidebar_categories ul li a:hover {
        color: #eaf5ff !important;
        background-color: #007fff;
        transition: background-color 0.25s ease;
        transition: color 0.25s ease;
    }
    

    #sideBarContents dl dt, #sideBarContents dl dd {
    /* 分别设置目录标题和子项的样式 */
    margin-top: 5px;
    }

    /*公告栏关于我*/
    #profile_avatar a img {
        float: left;
        margin-right: 10px; 
        margin-top: 5px;
        border: 2px solid #fff;
        transition: border-color 0.5s ease;
    }
    
    #profile_avatar img:hover {
        border: 2px solid #007fff;
        transition: border-color 0.5s ease;
    }

    /*隐藏*/
    #cnblogs_ch,#opt_under_post,#under_post_card1,#under_post_card2,.follow-tip,.under-post-card,#commentform_title,.comment-nav-right {
        display: none;
    }
    .postDesc a[href='https://www.cnblogs.com/xiins'] {
        display: none;
    }
    /*wap*/
    @media (max-width: 767px) {
       #navList,.blogStats,.post-view-count,.post-comment-count,.post-digg-count {
            display: none;
        }
    
    
        #sideBar {
          width: 0 !important;
          height: 100%!important;  /* 占满整个屏幕高度 */
          position: absolute!important;  /* 绝对定位 */
          top: 0!important;
          left: 0!important;
          transition: width 0.5s ease!important;
          overflow: hidden!important;
          z-index: 999!important;  /* 确保在上方显示 */
          display: none!important;  /* 初始不显示 */
        }
    
        #sideBar.open {
          width: 100%!important;  /* 展开时占满整个屏幕宽度 */
          display: block!important;
        }
    
        .close-btn {
          position: absolute!important;
          top: 10px!important;
          right: 10px!important;
          cursor: pointer!important;
          z-index: 1000!important;  /* 确保在上方显示 */
          display: none;  /* 初始不显示叉号 */
        }
        .open-btn {
          position: absolute!important;
          top: 10px!important;
          right: 10px!important;
          cursor: pointer!important;
          z-index: 998!important;  /* 确保在上方显示 */
        }
    
        .close-btn,.open-btn {
        background-color: rgb(255, 255, 255);  /* 初始背景色 */
        padding: 2px 15px 2px 15px;  /* 内边距,增加点击区域和美观度 */
        border-radius: 20px;  /* 圆角 */
        color: #007fff !important;  /* 文字颜色 */
        margin: 0px 0px 0px 5px;
        text-decoration: none !important;
        border: 1px solid #007fff;  
        font-size: 18px;
        }
    
        .close-btn:hover,.open-btn:hover {
        background-color: #eaf5ff;  /* 悬停时的背景色 */
        color: #007fff !important;  /* 悬停时的文字颜色 */
        border-color: #007fff !important;
        }
    }
    
    @media (min-width: 768px) {
     .open-btn,.close-btn {
        display: none;
      }
    }
    
    /*其他*/
    img.commenter-vip-logo {
    height: 14px;
    vertical-align: middle;
    }

页首Html代码

<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">

<script type="text/javascript">
var BlogDirectory = {
    /*
        获取元素位置,距浏览器左边界的距离(left)和距浏览器上边界的距离(top)
    */
    getElementPosition:function (ele) {        
        var topPosition = 0;
        var leftPosition = 0;
        while (ele){              
            topPosition += ele.offsetTop;
            leftPosition += ele.offsetLeft;        
            ele = ele.offsetParent;     
        }  
        return {top:topPosition, left:leftPosition}; 
    },

    /*
    获取滚动条当前位置
    */
    getScrollBarPosition:function () {
        var scrollBarPosition = document.body.scrollTop || document.documentElement.scrollTop;
        return  scrollBarPosition;
    },
    
    /*
    移动滚动条,finalPos 为目的位置,internal 为移动速度
    */
    moveScrollBar:function(finalpos, interval) {

        //若不支持此方法,则退出
        if(!window.scrollTo) {
            return false;
        }

        //窗体滚动时,禁用鼠标滚轮
        window.onmousewheel = function(){
            return false;
        };
          
        //清除计时
        if (document.body.movement) { 
            clearTimeout(document.body.movement); 
        } 

        var currentpos =BlogDirectory.getScrollBarPosition();//获取滚动条当前位置

        var dist = 0; 
        if (currentpos == finalpos) {//到达预定位置,则解禁鼠标滚轮,并退出
            window.onmousewheel = function(){
                return true;
            }
            return true; 
        } 
        if (currentpos < finalpos) {//未到达,则计算下一步所要移动的距离
            dist = Math.ceil((finalpos - currentpos)/10); 
            currentpos += dist; 
        } 
        if (currentpos > finalpos) { 
            dist = Math.ceil((currentpos - finalpos)/10); 
            currentpos -= dist; 
        }
        
        var scrTop = BlogDirectory.getScrollBarPosition();//获取滚动条当前位置
        window.scrollTo(0, currentpos);//移动窗口
        if(BlogDirectory.getScrollBarPosition() == scrTop)//若已到底部,则解禁鼠标滚轮,并退出
        {
            window.onmousewheel = function(){
                return true;
            }
            return true;
        }
        
        //进行下一步移动
        var repeat = "BlogDirectory.moveScrollBar(" + finalpos + "," + interval + ")"; 
        document.body.movement = setTimeout(repeat, interval); 
    },
    
    htmlDecode:function (text){
        var temp = document.createElement("div");
        temp.innerHTML = text;
        var output = temp.innerText || temp.textContent;
        temp = null;
        return output;
    },


        createBlogDirectory: function (id, mt, st, interval) {
            // 获取博文正文 div 容器
            var elem = document.getElementById(id);
            if (!elem) return false;
            // 获取 div 中所有元素结点
            var nodes = elem.getElementsByTagName("*");
            // 创建博客目录的 div 容器
            var divSideBar = document.createElement('DIV');
            divSideBar.className = 'uprightsideBar';
            divSideBar.setAttribute('id', 'uprightsideBar');

            // 将新创建的 div 放入指定的 div 中
            var sidebar = document.getElementById('sideBar');
            sidebar.appendChild(divSideBar);

            var divSideBarTab = document.createElement('DIV');
            divSideBarTab.setAttribute('id','sideBarTab');
            divSideBar.appendChild(divSideBarTab);
            var h2 = document.createElement('H2');
            divSideBarTab.appendChild(h2);
            var txt = document.createTextNode('目录导航');
            h2.appendChild(txt);
            var divSideBarContents = document.createElement('DIV');
            divSideBarContents.style.display = 'none';
            divSideBarContents.setAttribute('id', 'sideBarContents');
            divSideBar.appendChild(divSideBarContents);
            // 创建自定义列表
            var dlist = document.createElement("dl");
            divSideBarContents.appendChild(dlist);
            var num = 0;// 统计找到的 mt 和 st
            mt = mt.toUpperCase();// 转化成大写
            st = st.toUpperCase();// 转化成大写
            // 遍历所有元素结点
            for (var i = 0; i < nodes.length; i++) {
                var tits = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
                if (tits.indexOf(nodes[i].nodeName)!== -1) { 
                    // 获取标题文本
                    var nodetext = nodes[i].innerHTML.replace(/<\/?[^>]+>/g,"");
                    nodetext = BlogDirectory.htmlDecode(nodetext);
                    // 插入锚
                    nodes[i].setAttribute("id", "blogTitle" + num);
                    var item;
                    switch (nodes[i].nodeName) {
                        case 'H1':    // 若为主标题
                            item = document.createElement("dt");
                            break;
                        case 'H3':
                            item = document.createElement("dd");
                            item.setAttribute('class', 'indent3');
                            break;
                        case 'H4':
                            item = document.createElement("dd");
                            item.setAttribute('class', 'indent4');
                            break;
                        case 'H5':
                            item = document.createElement("dd");
                            item.setAttribute('class', 'indent5');
                            break;
                        case 'H6':
                            item = document.createElement("dd");
                            item.setAttribute('class', 'indent6');
                            break;
                        default:    // 若为子标题
                            item = document.createElement("dd");
                            break;
                    }

                    // 创建锚链接
                    var itemtext = document.createTextNode(nodetext);
                    item.appendChild(itemtext);
                    item.setAttribute("name", num);
                    item.onclick = function () {        // 添加鼠标点击触发函数
                        var pos = BlogDirectory.getElementPosition(document.getElementById("blogTitle" + this.getAttribute("name")));
                        if (!BlogDirectory.moveScrollBar(pos.top, interval)) return false;
                    };

                    // 将自定义表项加入自定义列表中
                    dlist.appendChild(item);
                    num++;
                }
            }
            divSideBarContents.style.display = 'block';

            // 如果没有找到标题,则不生成目录导航栏
            if (num == 0) return false;
            /*鼠标进入时的事件处理*/
            // divSideBarTab.onmouseenter = function(){
            //     divSideBarContents.style.display = 'block';
            // }

            /*鼠标离开时的事件处理*/
            // divSideBar.onmouseleave = function() {
            //     divSideBarContents.style.display = 'none';
            // }

            /*鼠标点击时的事件处理*/
            divSideBarTab.onclick = function () {
                if (divSideBarContents.style.display == "none")
                    divSideBarContents.style.display = 'block';
                else {
                    divSideBarContents.style.display = 'none';
                }
            }
        }
    };

    window.onload = function () {
        /*页面加载完成之后生成博客目录*/
        BlogDirectory.createBlogDirectory("cnblogs_post_body", "h1", "h2", 20);
    }
</script>

<script>
    function openSideBar() {
      document.getElementById('sideBar').classList.add('open');
    }

    function closeSideBar() {
      document.getElementById('sideBar').classList.remove('open');
    }


    function openSideBar() {
      document.getElementById('sideBar').classList.add('open');
      document.querySelector('.close-btn').style.display = 'block';  // 显示叉号
    }

    function closeSideBar() {
      document.getElementById('sideBar').classList.remove('open');
      document.querySelector('.close-btn').style.display = 'none';  // 隐藏叉号
    }
</script>

页脚Html代码

  <button class="open-btn" onclick="openSideBar()">···</button>
  <button class="close-btn" onclick="closeSideBar()">×</button>

<script type="text/javascript">
if (window.location.pathname === '/xiins') { 
  // 获取所有的 postTitle 元素
  var postTitles = document.querySelectorAll('.postTitle');

  postTitles.forEach(function(postTitle) {
    var current = postTitle;
    var wrapperDiv = null;

    while (current) {
      if (current.classList.contains('postSeparator')) {
        break;
      }

      if (!wrapperDiv) {
        wrapperDiv = document.createElement('div');
        wrapperDiv.classList.add('article-wrapper');
        current.parentNode.insertBefore(wrapperDiv, current);
      }

      // 移动当前元素及其所有子元素到新的包裹 div 中
      var children = Array.from(current.childNodes);
      children.forEach(function(child) {
        wrapperDiv.appendChild(child);
      });

      current = current.nextElementSibling;
    }
  });
}
</script>

<script>
    if (window.location.pathname === '/xiins') {
      var divs = document.getElementsByClassName('forFlow');
      for (var i = 0; i < divs.length; i++) {
        divs[i].style.margin = '10px 0'; 
      }
    }
</script>

<script>
var footer = document.getElementById('footer');
var text = footer.innerHTML;

text = text.replace('学海人', '学海人 - xiin');
text = text.replace('Kubernetes', 'Kubernetes. Themed by LessIsRichness Light.');

footer.innerHTML = text;
</script>
<script>
// 等待页面加载完成
window.addEventListener('load', function() {
  var postDesc = document.querySelector('.postDesc');
  var text = postDesc.innerHTML;
  text = text.replace('posted @', '发布于');
  postDesc.innerHTML = text;
});
</script>
<script>
// 等待页面加载完成
window.addEventListener('load', function() {
  // 获取所有的链接元素
  var links = document.getElementsByTagName('a');

  // 遍历链接元素
  for (var i = 0; i < links.length; i++) {
    // 如果链接文本包含 "学海人"
    if (links[i].innerHTML.includes('学海人')) {
      // 创建一个新的图像元素
      var img = document.createElement('img');
      img.src = '/i/l/?n=24&i=blog/3501016/202408/3501016-20240812105915804-1642176338.png';  // 替换为您的图标 URL
      img.className = 'commenter-vip-logo';  // 添加类名

      // 将图像元素添加到链接后面
      links[i].appendChild(img);
    }
  }
});
</script>

结语

魔改主题LessIsRichness可以免费使用,禁止用于商业用途,请在footer保留魔改主题名称LessIsRichness,欢迎二次魔改。

主题尚未完善,如有问题,欢迎指正。这是来博客园的第一篇随笔,希望以后能在这里记录我的学习历程!

标签:less,color,博客园,魔改,important,background,10px,0px,margin
From: https://www.cnblogs.com/xiins/p/18354995

相关文章

  • 1.markdown文档同步到博客园
    1.markdown文档同步到博客园1.1安装.NETFramework3.5打开控制面板\程序\程序和功能\启用或关闭Windows功能,如下图所示操作1.2安装dotnet-sdk-5.0.408-win-x64.exe1.3命令dotnettoolinstall-g--version1.4.0dotnet-cnblogdotnet-cnblogdotnet-cnblogreset......
  • linux command --- less more(分页输出文件内容)
    lessless命令用于显示文件或命令输出的内容,它一次只显示一个页面(分页显示工具)。它类似于more命令,但less具有更高级的功能,它允许您在文件中向前和向后导航。less命令主要用于打开大文件,less不会读取整个文件,相比于vim或nano等文本编辑器,加载时间会更快。less命令的语法格式......
  • 博客园自定义皮肤工具推荐:awescnb
    简介awescnb是一个用于博客园(Cnblogs)的自定义皮肤和功能增强插件。它允许用户通过简单的配置来自定义其博客的外观和增加一些额外的功能。下面是对awescnb的简要介绍:功能特点:自定义皮肤:用户可以选择不同的皮肤主题,包括背景颜色、字体样式等,以个性化他们的博客页面。扩展......
  • 博客园自定义皮肤工具推荐:awescnb
    简介awescnb是一个用于博客园(Cnblogs)的自定义皮肤和功能增强插件。它允许用户通过简单的配置来自定义其博客的外观和增加一些额外的功能。下面是对awescnb的简要介绍:功能特点:自定义皮肤:用户可以选择不同的皮肤主题,包括背景颜色、字体样式等,以个性化他们的博客页面。扩展功能:除......
  • 博客园自救之产品开发小建议
     继上次博客园直播方向运营建议之后,我又冒出了一个小建议, 毕竟作为博客园精神股东,开动我脑洞,我也义不容辞责任 博客园的产品形式是博客文章,拓展路径有两条,一条是文章的分类,一条的是文章的内容 分类的控制权在博客园,可拓展性强 内容的控制权在文章作者,可获站性弱 所......
  • 华为云全域Serverless技术创新:全球首创通用Serverless平台被ACM SIGCOMM录用
    摘要:该平台提供通用函数编程模型,高可扩缩、高性能和高效对接后端服务的运行框架,助力华为云构建全域Serverless云服务。华为开发者大会2024(HDC2024)在东莞·松山湖圆满结束,期间华为云主办的“全域Serverless时代:技术创新引领,赋能行业实践”专题论坛,向广大开发者传递了Serverless领......
  • WPFUI报错 - page does not have a parameterless constructor
    WPFUI报错pagedoesnothaveaparameterlessconstructor.IfyouareusingWpf.Ui.IPageServicedonotnavigateinitiallyanddon'tuseCacheorPrecache问题原因WPFUI中的NavigationView只支持导航页面的无参构造函数或含一个dataContext的有参构造函数。因为在View......
  • Endless Wander(漫无止境)手游攻略个人总结记录(有空更新)
    "AmysteriousPortalsealedforyearsreopens,offeringachanceforNovutosavehissistertrappedinsideandtorebuildtheWanderer'sGuild."EndlessWanderisanofflineroguelikeRPGinapixelartstyle.Itfeaturessatisfyingandch......
  • vue-seamless-scroll插件点击事件不生效
    vue-seamless-scroll点击事件不生效问题:在使用此插件时发现,列表内容前几行还是能正常点击的,但是从第二次出现的列表开始就没有点击事件了原因:因为html元素是复制出来的(滚动组件是将后面的复制出来一份,进行填铺页面,方便滚动)解决:往滚动组件的父节点上添加绑定事件(js冒泡机制),通过......
  • 参加阿里云X优酷AI江湖创作大赛,赠送博客园T恤
    大赛官网:https://developer.aliyun.com/plan/create/snbm8月刚开始就接到一个阿里云的广告单子,也是CPA(CostPerAction)方式,按有效参赛人数付费,KPI是完成500人参赛。参赛方式是基于阿里云函数计算服务部署的AI绘画平台创作图片作品。(注:函数计算服务有免费试用额度,使用这个额......