跳到正文

科技·工程

更改洛谷背景,实现半透明洛谷

Stella7约 28 分钟
原文

这是 2026年8月15日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年8月10日
收录
2026年8月15日
更新
2026年11月21日
篇幅
约 28 分钟
获赞
1

版本

  1. v2当前
  2. v1

我们几乎每天都会打开洛谷

并且每天都会看到一篇白白的背景板,主题也有限制 说白了就是不好看

![原版洛谷] 所以之前我也查阅了洛谷中的文章,法相各位大佬的操作学不会啊…

(stylish没法用了,氢洛谷也下载不到,也太麻烦了嘛awa)

于是!!!

天才如我,我打开了stylus,点击了新建, 打开了deepseek… deepseek也是非常配合,在我和他的共同努力下,成功找到了覆盖洛谷背景的办法

JavaScript
/* ========================================
   洛谷银狼背景 - 全站完整版(白底代码框,排除IDE)
   ======================================== */



    
    /* ===== 1. html 设银狼背景 ===== */
    html {
        background: url('https://upload-bbs.miyoushe.com/upload/2024/03/07/292762008/d322f983c4769b8b5ee68dc89c3e1f18_185113016625097727.png') fixed center 15% / cover no-repeat !important;
        min-height: 100vh !important;
        background-color: transparent !important;
    }

    /* ===== 2. body 透明 ===== */
    body {
        background: transparent !important;
        min-height: 100vh !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ===== 3. #app 透明 ===== */
    #app {
        background: transparent !important;
    }

    /* ===== 4. 清除所有背景和遮罩 ===== */
    .theme-page,
    .theme-frosted,
    .record-main,
    .record-page,
    [class*="record"],
    .lfe-body-mid {
        --theme-body-image: none !important;
        --theme-body-image-size: none !important;
        --theme-body-mid-mask: none !important;
        --theme-body-back: transparent !important;
        background-image: none !important;
        background: transparent !important;
        background-color: transparent !important;
    }

    .lfe-body-mid::before,
    .lfe-body-mid::after,
    .theme-page::before,
    .theme-page::after {
        display: none !important;
        content: none !important;
        opacity: 0 !important;
    }

    /* ===== 5. 所有容器默认透明 ===== */
    .columba-content-wrap,
    .header-layout,
    .header-block,
    .top-row,
    .left,
    .right,
    .bottom-row,
    .sidebar-container,
    .side,
    .main,
    .stat,
    .field,
    .items,
    .menu,
    .btn-actions,
    .l-flex-info-row,
    .provider-display,
    .luogu-username,
    .tags,
    .expand-indicator,
    .problem-block-actions,
    footer,
    main,
    header,
    [class*="lfe"],
    .lg-nav,
    .lg-header,
    .header,
    .navbar {
        background: transparent !important;
        background-color: transparent !important;
    }

    /* ===== 6. 内容卡片半透明 ===== */
    .l-card,
    .problem,
    .main > .l-card,
    .side > .l-card,
    .header-card,
    .card,
    .panel,
    .am-panel,
    .am-panel-default,
    .am-panel-bd {
        background: rgba(255, 255, 255, 0.5) !important;
        background-color: rgba(255, 255, 255, 0.5) !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    /* ===== 7. 统计信息行 ===== */
    .stat.stacked {
        background: rgba(255, 255, 255, 0.3) !important;
        background-color: rgba(255, 255, 255, 0.3) !important;
        border-radius: 8px !important;
        padding: 8px 12px !important;
    }

    /* ===== 8. markdown 内容块 ===== */
    .lfe-marked-wrap {
        background: rgba(255, 255, 255, 0.2) !important;
        background-color: rgba(255, 255, 255, 0.2) !important;
        padding: 8px 12px !important;
        border-radius: 6px !important;
        margin: 8px 0 !important;
    }

    /* ===== 9. 样例输入输出 ===== */
    .io-sample-block {
        background: rgba(255, 255, 255, 0.85) !important;
        background-color: rgba(255, 255, 255, 0.85) !important;
        border-radius: 6px !important;
        margin: 4px 0 !important;
        padding: 4px !important;
        border: 1px solid rgba(200, 200, 200, 0.3) !important;
    }

    .io-sample-block pre,
    .io-sample-block .lfe-code {
        background: rgba(248, 248, 248, 0.95) !important;
        background-color: rgba(248, 248, 248, 0.95) !important;
        border-radius: 4px !important;
        padding: 12px 16px !important;
        color: #1a1a2e !important;
    }

    /* ===== 10. 评测记录页面 ===== */
    .record-main,
    .record-page,
    [class*="record"] {
        background: transparent !important;
        background-color: transparent !important;
    }

    .record-main .l-card,
    .record-page .l-card {
        background: rgba(255, 255, 255, 0.5) !important;
        background-color: rgba(255, 255, 255, 0.5) !important;
    }

    .record-header,
    .record-top,
    [class*="record-header"],
    [class*="record-top"] {
        --theme-body-mid-mask: none !important;
        background: rgba(255, 255, 255, 0.5) !important;
        background-color: rgba(255, 255, 255, 0.5) !important;
    }

    /* ===== 11. 标题颜色 ===== */
    h1, h2, h3, h4, h5, h6,
    .lfe-h1, .lfe-h2, .lfe-h3,
    .title, .stat-text {
        color: #1a1a2e !important;
    }

    /* ===== 12. 正文 ===== */
    p, div, span, li, .lfe-caption, ul, ol {
        color: #1a1a2e !important;
    }

    /* ===== 13. 链接 ===== */
    a {
        color: #1a73e8 !important;
    }

    /* ===== 14. 输入框、按钮白色 ===== */
    input, select, textarea, button,
    .lform-size-middle, .lform-size-small,
    .am-btn, .am-form-control {
        background: #ffffff !important;
        background-color: #ffffff !important;
    }

    /* ===== 15. 导航栏 ===== */
    .lg-nav,
    .lg-header {
        background: rgba(255, 255, 255, 0.6) !important;
        background-color: rgba(255, 255, 255, 0.6) !important;
    }

    /* ===== 16. 题单页 ===== */
    body > ul > li {
        background: rgba(255, 255, 255, 0.3) !important;
        background-color: rgba(255, 255, 255, 0.3) !important;
        padding: 8px 12px !important;
        margin: 4px 0 !important;
        border-radius: 6px !important;
        list-style: none !important;
    }

    body > ul {
        padding-left: 0 !important;
        list-style: none !important;
    }

    body > span > a {
        display: inline-block !important;
        background: rgba(255, 255, 255, 0.4) !important;
        background-color: rgba(255, 255, 255, 0.4) !important;
        padding: 4px 12px !important;
        margin: 2px 4px !important;
        border-radius: 12px !important;
        text-decoration: none !important;
    }

    /* ===== 17. 分割线 ===== */
    hr {
        border-color: rgba(0, 0, 0, 0.1) !important;
    }

    /* ===== 18. 强制覆盖行内白色背景 ===== */
    [style*="background: rgba(255, 255, 255, 0.3)"] {
        background: transparent !important;
        background-color: transparent !important;
    }
    
    /* ===== 19. .theme-page 特殊处理 ===== */
    .theme-page {
        background: transparent !important;
        background-color: transparent !important;
    }

    /* ===== 20. 评测记录页面 - 强制清除黑条 ===== */
    .record-list,
    .record-list .theme-page,
    .record-list .theme-frosted,
    .record-list .record-header,
    .record-list .record-top,
    .record-list [class*="record-header"],
    .record-list [class*="record-top"],
    body > .theme-page,
    .record-main {
        --theme-body-mid-mask: none !important;
        --theme-body-image: none !important;
        background: transparent !important;
        background-color: transparent !important;
        background-image: none !important;
    }

    [style*="theme-body-mid-mask"] {
        --theme-body-mid-mask: none !important;
    }

    [style*="linear-gradient"] {
        background: transparent !important;
        background-color: transparent !important;
        background-image: none !important;
    }

    .record-list .l-card,
    .record-list .columba-content-wrap,
    .record-list .main {
        background: rgba(255, 255, 255, 0.5) !important;
        background-color: rgba(255, 255, 255, 0.5) !important;
    }

    html {
        --theme-body-mid-mask: none !important;
    }

    * {
        --theme-body-mid-mask: none !important;
    }

    /* ===== 21. 题解页面内容块 ===== */
    .solution-content .lfe-marked-wrap,
    .problem-solution .lfe-marked-wrap,
    .solution-main .lfe-marked-wrap {
        background: rgba(255, 255, 255, 0.15) !important;
        background-color: rgba(255, 255, 255, 0.15) !important;
        padding: 8px 12px !important;
        border-radius: 6px !important;
        margin: 8px 0 !important;
    }

    .solution-content .l-card,
    .problem-solution .l-card,
    .solution-main .l-card {
        background: rgba(255, 255, 255, 0.5) !important;
        background-color: rgba(255, 255, 255, 0.5) !important;
    }

    .solution-content p,
    .solution-content div,
    .solution-content span,
    .problem-solution p,
    .problem-solution div,
    .problem-solution span {
        color: #1a1a2e !important;
    }

    .solution-content h1,
    .solution-content h2,
    .solution-content h3,
    .solution-content h4,
    .problem-solution h1,
    .problem-solution h2,
    .problem-solution h3,
    .problem-solution h4 {
        color: #1a1a2e !important;
    }

    .solution-content a,
    .problem-solution a {
        color: #1a73e8 !important;
    }

    .solution-content table,
    .problem-solution table {
        background: rgba(255, 255, 255, 0.3) !important;
        background-color: rgba(255, 255, 255, 0.3) !important;
    }

    .solution-content th,
    .solution-content td,
    .problem-solution th,
    .problem-solution td {
        color: #1a1a2e !important;
    }

    .solution-content blockquote,
    .problem-solution blockquote {
        background: rgba(255, 255, 255, 0.2) !important;
        background-color: rgba(255, 255, 255, 0.2) !important;
        border-left: 4px solid rgba(26, 115, 232, 0.5) !important;
        padding: 8px 16px !important;
        margin: 8px 0 !important;
    }

    /* ==========================================
       白底代码框 - 只改普通页面,排除IDE
       ========================================== */

    /* 只匹配题解页面和普通页面的代码框,排除 IDE */
    .solution-content pre,
    .solution-content code,
    .solution-content .lfe-code,
    .problem-solution pre,
    .problem-solution code,
    .solution-main pre,
    .solution-main code,
    [class*="solution"] pre,
    [class*="solution"] code,
    [class*="solution"] .lfe-code,
    .lfe-marked pre,
    .lfe-marked code,
    .lfe-marked-wrap pre,
    .lfe-marked-wrap code,
    .io-sample-block pre,
    .io-sample-block .lfe-code {
        background: #ffffff !important;
        background-color: #ffffff !important;
        color: #1a1a2e !important;
        border-radius: 6px !important;
        padding: 12px 16px !important;
        font-family: "Consolas", monospace !important;
        font-size: 14px !important;
        line-height: 1.7 !important;
        border: 1px solid #e0e0e0 !important;
    }

    /* 代码框内所有文字 - 深色 */
    .solution-content pre *,
    .solution-content code *,
    .solution-content .lfe-code *,
    .problem-solution pre *,
    .problem-solution code *,
    .solution-main pre *,
    .solution-main code *,
    [class*="solution"] pre *,
    [class*="solution"] code *,
    .lfe-marked pre *,
    .lfe-marked code *,
    .io-sample-block pre *,
    .io-sample-block .lfe-code * {
        color: #1a1a2e !important;
    }

    /* ===== 语法高亮颜色 ===== */
    .solution-content .hljs-keyword,
    .problem-solution .hljs-keyword,
    .solution-main .hljs-keyword,
    .lfe-marked .hljs-keyword {
        color: #0000ff !important;
    }
    .solution-content .hljs-built_in,
    .problem-solution .hljs-built_in,
    .solution-main .hljs-built_in,
    .lfe-marked .hljs-built_in {
        color: #0086b3 !important;
    }
    .solution-content .hljs-type,
    .problem-solution .hljs-type,
    .solution-main .hljs-type,
    .lfe-marked .hljs-type {
        color: #2b6ba0 !important;
    }
    .solution-content .hljs-string,
    .problem-solution .hljs-string,
    .solution-main .hljs-string,
    .lfe-marked .hljs-string {
        color: #008000 !important;
    }
    .solution-content .hljs-number,
    .problem-solution .hljs-number,
    .solution-main .hljs-number,
    .lfe-marked .hljs-number {
        color: #098658 !important;
    }
    .solution-content .hljs-comment,
    .problem-solution .hljs-comment,
    .solution-main .hljs-comment,
    .lfe-marked .hljs-comment {
        color: #008000 !important;
        font-style: italic !important;
    }
    .solution-content .hljs-function,
    .problem-solution .hljs-function,
    .solution-main .hljs-function,
    .lfe-marked .hljs-function {
        color: #795e26 !important;
    }
    .solution-content .hljs-title,
    .problem-solution .hljs-title,
    .solution-main .hljs-title,
    .lfe-marked .hljs-title {
        color: #001080 !important;
    }
    .solution-content .hljs-params,
    .problem-solution .hljs-params,
    .solution-main .hljs-params,
    .lfe-marked .hljs-params {
        color: #001080 !important;
    }
    .solution-content .hljs-meta,
    .problem-solution .hljs-meta,
    .solution-main .hljs-meta,
    .lfe-marked .hljs-meta {
        color: #808080 !important;
    }
    .solution-content .hljs-literal,
    .problem-solution .hljs-literal,
    .solution-main .hljs-literal,
    .lfe-marked .hljs-literal {
        color: #0000ff !important;
    }
    .solution-content .hljs-macro,
    .problem-solution .hljs-macro,
    .solution-main .hljs-macro,
    .lfe-marked .hljs-macro {
        color: #795e26 !important;
    }
    .solution-content .hljs-preprocessor,
    .problem-solution .hljs-preprocessor,
    .solution-main .hljs-preprocessor,
    .lfe-marked .hljs-preprocessor {
        color: #808080 !important;
    }

    /* ===== 行内代码(段落里的) ===== */
    .solution-content p code,
    .problem-solution p code,
    .solution-main p code,
    .lfe-marked p code {
        background: #f5f5f5 !important;
        background-color: #f5f5f5 !important;
        color: #d14 !important;
        padding: 2px 6px !important;
        border-radius: 3px !important;
        font-size: 0.9em !important;
        border: 1px solid #e8e8e8 !important;
    }

我发现洛谷源代码竟然毫无隐瞒,如此的容易,我们把代码放到stylus中,保存。

重新打开洛谷,啊~~

由于我的只是有限,也就只能做到这个程度了,勿喷啊。

自我感觉还行了,

这背景怪难处理