{"id":212,"date":"2025-12-01T19:12:34","date_gmt":"2025-12-01T11:12:34","guid":{"rendered":"https:\/\/caoxunyi.cn\/?p=212"},"modified":"2025-12-01T19:15:16","modified_gmt":"2025-12-01T11:15:16","slug":"%e5%89%8d%e7%ab%af%e5%ae%9e%e6%88%98%e6%8a%9b%e5%bc%83%e7%ac%a8%e9%87%8d%e7%9a%84%e5%ba%93%ef%bc%81%e6%89%8b%e6%90%93%e4%b8%80%e4%b8%aa%e7%b1%bb%e4%bc%bc-pixiv-%e7%9a%84%e5%93%8d%e5%ba%94%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/caoxunyi.cn\/index.php\/212\/","title":{"rendered":"[\u524d\u7aef\u5b9e\u6218]\u629b\u5f03\u7b28\u91cd\u7684\u5e93\uff01\u624b\u6413\u4e00\u4e2a\u7c7b\u4f3c Pixiv \u7684\u54cd\u5e94\u5f0f\u7011\u5e03\u6d41\u753b\u5eca"},"content":{"rendered":"<blockquote>\n<p><strong>\u524d\u8a00<\/strong>\n\u6700\u8fd1\u5728\u7f16\u5199\u6211\u7684web\u5927\u4f5c\u4e1a\u7684\u753b\u5eca\u9875\u9762\u3002\u6700\u5f00\u59cb\u662f\u628a\u56fe\u7247\u5f3a\u884c\u88c1\u526a\u6210\u6b63\u65b9\u5f62\uff0c\u611f\u89c9\u5931\u53bb\u4e86\u7075\u9b42\u3002\n\u6211\u60f3\u8981\u4e00\u79cd\u50cf <strong>Pixiv<\/strong> \u6216 <strong>Pinterest<\/strong> \u90a3\u6837\u7684<strong>\u7011\u5e03\u6d41\u5e03\u5c40 (Masonry Layout)<\/strong>\uff1a\u56fe\u7247\u5bbd\u5ea6\u56fa\u5b9a\uff0c\u9ad8\u5ea6\u81ea\u9002\u5e94\uff0c\u9519\u843d\u6709\u81f4\u3002\n\u7814\u7a76\u4e86\u4e00\u5708\uff0c\u53d1\u73b0\u7528\u7eaf CSS \u7684 <code>column-count<\/code> \u5c31\u80fd\u5b8c\u7f8e\u5b9e\u73b0\uff0c\u914d\u5408\u4e00\u70b9\u539f\u751f JS \u5c31\u80fd\u641e\u5b9a\u9884\u89c8\u548c\u70b9\u8d5e\u3002\u4eca\u5929\u5c31\u6765\u5206\u4eab\u4e00\u4e0b\u6211\u662f\u600e\u4e48\u201c\u624b\u6413\u201d\u8fd9\u4e2a\u529f\u80fd\u7684\u3002<\/p>\n<\/blockquote>\n<h2>\u6700\u7ec8\u6548\u679c\u76ee\u6807<\/h2>\n<ol>\n<li><strong>\u7011\u5e03\u6d41\u6392\u7248<\/strong>\uff1a\u591a\u5217\u5e03\u5c40\uff0c\u56fe\u7247\u4fdd\u6301\u539f\u59cb\u6bd4\u4f8b\uff0c\u4e0d\u88ab\u88c1\u5207\u3002<\/li>\n<li><strong>\u54cd\u5e94\u5f0f\u9002\u914d<\/strong>\uff1a\u4ece\u624b\u673a\u7684\u53cc\u5217\u5230\u5927\u5c4f\u7684\u4e94\u5217\uff0c\u4e1d\u6ed1\u5207\u6362\u3002<\/li>\n<li><strong>\u4ea4\u4e92\u4f53\u9a8c<\/strong>\uff1a\u5361\u7247\u60ac\u505c\u4e0a\u6d6e\u3001\u7231\u5fc3\u70b9\u8d5e\u5207\u6362\u3001\u70b9\u51fb\u67e5\u770b\u5927\u56fe (Lightbox)\u3002<\/li>\n<li>\n<h2 class=\"alignnone\"><strong>\u6df1\u8272\u6a21\u5f0f<\/strong>\uff1a\u81ea\u52a8\u9002\u914d\u591c\u95f4\u6d4f\u89c8\uff0c\u4fdd\u62a4\u89c6\u529b\u3002\n<figure id=\"attachment_mmd_213\" class=\"wp-block-image \"><img width=\"700\" height=\"330\" src=\"https:\/\/caoxunyi.cn\/wp-content\/uploads\/2025\/12\/1764587525-acfdccfa10d67f469eac99cb5f400b60-scaled.png\" class=\"attachment-700x400 size-700x400\" alt=\"1764587525-acfdccfa10d67f469eac99cb5f400b60\" decoding=\"async\" loading=\"lazy\" srcset=\"https:\/\/caoxunyi.cn\/wp-content\/uploads\/2025\/12\/1764587525-acfdccfa10d67f469eac99cb5f400b60-scaled.png 2560w, https:\/\/caoxunyi.cn\/wp-content\/uploads\/2025\/12\/1764587525-acfdccfa10d67f469eac99cb5f400b60-300x141.png 300w, https:\/\/caoxunyi.cn\/wp-content\/uploads\/2025\/12\/1764587525-acfdccfa10d67f469eac99cb5f400b60-1024x482.png 1024w, https:\/\/caoxunyi.cn\/wp-content\/uploads\/2025\/12\/1764587525-acfdccfa10d67f469eac99cb5f400b60-768x362.png 768w, https:\/\/caoxunyi.cn\/wp-content\/uploads\/2025\/12\/1764587525-acfdccfa10d67f469eac99cb5f400b60-1536x724.png 1536w, https:\/\/caoxunyi.cn\/wp-content\/uploads\/2025\/12\/1764587525-acfdccfa10d67f469eac99cb5f400b60-2048x965.png 2048w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/figure><\/h2>\n<\/li>\n<\/ol>\n<h2>\u7b2c\u4e00\u6b65\uff1aHTML \u7ed3\u6784\u8bbe\u8ba1<\/h2>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u6e05\u6670\u7684\u5bb9\u5668\u7ed3\u6784\u3002\u8fd9\u91cc\u6211\u91c7\u7528\u4e86\u201c\u5bb9\u5668 + \u5361\u7247\u201d\u7684\u5305\u88f9\u6a21\u5f0f\u3002<\/p>\n<pre><code class=\"lang-html language-html html\">&lt;div class=&quot;gallery-container&quot;&gt;\n    &lt;div class=&quot;gallery-item&quot;&gt;\n        &lt;div class=&quot;image-wrapper&quot;&gt;\n            &lt;img src=&quot;path\/to\/miku.jpg&quot; alt=&quot;Miku Image&quot;&gt;\n        &lt;\/div&gt;\n        &lt;div class=&quot;item-info&quot;&gt;\n            &lt;span class=&quot;item-title&quot;&gt;\u4e16\u754c\u7b2c\u4e00\u516c\u4e3b\u6bbf\u4e0b&lt;\/span&gt;\n            &lt;button class=&quot;like-btn&quot;&gt;\u2661&lt;\/button&gt;\n        &lt;\/div&gt;\n    &lt;\/div&gt;\n    &lt;\/div&gt;\n\n&lt;div id=&quot;lightbox&quot; class=&quot;lightbox&quot;&gt;\n    &lt;span class=&quot;close-btn&quot;&gt;&amp;times;&lt;\/span&gt;\n    &lt;img id=&quot;lightbox-img&quot; src=&quot;&quot;&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<hr \/>\n<h2>\u7b2c\u4e8c\u6b65\uff1aCSS \u6838\u5fc3\u5e03\u5c40 (Magic Time)<\/h2>\n<p>\u8fd9\u662f\u5b9e\u73b0\u7011\u5e03\u6d41\u6700\u5173\u952e\u7684\u4e00\u6b65\u3002\u5f88\u591a\u6559\u7a0b\u5efa\u8bae\u7528 JS \u8ba1\u7b97\u4f4d\u7f6e\uff0c\u4f46\u5176\u5b9e CSS \u7684 <strong>Multi-column \u5c5e\u6027<\/strong> \u624d\u662f\u6700\u8f7b\u91cf\u7ea7\u7684\u89e3\u6cd5\u3002<\/p>\n<h3>1. \u5f00\u542f\u7011\u5e03\u6d41<\/h3>\n<p>\u6211\u4eec\u5728\u5bb9\u5668\u4e0a\u5b9a\u4e49\u5217\u6570 (<code>column-count<\/code>) \u548c\u5217\u95f4\u8ddd (<code>column-gap<\/code>)\u3002<\/p>\n<pre><code class=\"lang-css language-css css\">.gallery-container {\n    width: 100%;\n    max-width: 1400px;\n    margin: 0 auto;\n    padding: 20px 30px 80px;\n\n    \/* \u6838\u5fc3\u4ee3\u7801\uff1a5\u5217\u5e03\u5c40\uff0c\u95f4\u8ddd16px *\/\n    column-count: 5;\n    column-gap: 16px;\n}<\/code><\/pre>\n<h3>2. \u9632\u6b62\u5361\u7247\u65ad\u88c2<\/h3>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u591a\u5217\u5e03\u5c40\u53ef\u80fd\u4f1a\u628a\u4e00\u4e2a\u5143\u7d20\u4ece\u4e2d\u95f4\u201c\u5207\u5f00\u201d\u653e\u5230\u4e0b\u4e00\u5217\u3002\u6211\u4eec\u9700\u8981\u7ed9\u5361\u7247\u52a0\u4e0a <code>break-inside: avoid<\/code>\u3002<\/p>\n<pre><code class=\"lang-css language-css css\">.gallery-item {\n    break-inside: avoid;  \/* \u5173\u952e\uff1a\u9632\u6b62\u5361\u7247\u88ab\u5206\u5272\u5230\u591a\u5217 *\/\n    margin-bottom: 16px;  \/* \u5361\u7247\u5782\u76f4\u95f4\u8ddd *\/\n    background: #fff;\n    border-radius: 16px;\n    overflow: hidden;\n\n    \/* \u52a0\u4e0a\u4e00\u70b9\u9634\u5f71\u8ba9\u5b83\u6d6e\u8d77\u6765 *\/\n    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);\n    transition: transform 0.3s ease, box-shadow 0.3s ease;\n}\n\n\/* \u65e2\u7136\u662f Miku \u4e3b\u9898\uff0c\u60ac\u505c\u65f6\u6765\u70b9\u521d\u97f3\u7eff\u7684\u8f89\u5149 *\/\n.gallery-item:hover {\n    transform: translateY(-4px);\n    box-shadow: 0 12px 30px rgba(57, 197, 187, 0.25);\n}<\/code><\/pre>\n<h3>3. \u54cd\u5e94\u5f0f\u65ad\u70b9<\/h3>\n<p>\u4e3a\u4e86\u5728\u4e0d\u540c\u8bbe\u5907\u4e0a\u90fd\u6709\u5b8c\u7f8e\u7684\u4f53\u9a8c\uff0c\u6211\u8bbe\u7f6e\u4e86\u591a\u4e2a\u65ad\u70b9\u6765\u8c03\u6574\u5217\u6570\uff1a<\/p>\n<ul>\n<li><strong>PC \u5927\u5c4f<\/strong>: 5\u5217<\/li>\n<li><strong>\u7b14\u8bb0\u672c<\/strong>: 4\u5217<\/li>\n<li><strong>\u5e73\u677f<\/strong>: 3\u5217<\/li>\n<li><strong>\u624b\u673a<\/strong>: 2\u5217<\/li>\n<\/ul>\n<!-- end list -->\n<pre><code class=\"lang-css language-css css\">@media (max-width: 1200px) { .gallery-container { column-count: 4; } }\n@media (max-width: 991px)  { .gallery-container { column-count: 3; } }\n@media (max-width: 767px)  { .gallery-container { column-count: 2; } }<\/code><\/pre>\n<hr \/>\n<h2>\u7b2c\u4e09\u6b65\uff1a\u539f\u751f JS \u5b9e\u73b0\u4ea4\u4e92<\/h2>\n<p>\u6211\u4e0d\u559c\u6b22\u4e3a\u4e86\u4e00\u4e2a\u5c0f\u5c0f\u7684\u201c\u70b9\u51fb\u653e\u5927\u201d\u529f\u80fd\u5c31\u5f15\u5165 jQuery \u6216\u5176\u4ed6\u63d2\u4ef6\u3002\u624b\u5199\u4e00\u6bb5\u539f\u751f JS \u5176\u5b9e\u975e\u5e38\u7b80\u5355\u3002<\/p>\n<h3>1. \u7231\u5fc3\u70b9\u8d5e\u529f\u80fd<\/h3>\n<p>\u5229\u7528 <code>classList.toggle<\/code> \u5207\u6362\u7c7b\u540d\uff0c\u987a\u4fbf\u6539\u53d8\u6587\u5b57\u5185\u5bb9\uff08\u5b9e\u5fc3\u5fc3\/\u7a7a\u5fc3\u5fc3\uff09\u3002<\/p>\n<pre><code class=\"lang-javascript language-javascript javascript\">const likeBtn = item.querySelector('.like-btn');\n\nlikeBtn.addEventListener('click', (e) =&gt; {\n    e.stopPropagation(); \/\/ \u9632\u6b62\u5192\u6ce1\u89e6\u53d1\u67e5\u770b\u5927\u56fe\n    likeBtn.classList.toggle('liked');\n\n    \/\/ \u5207\u6362\u89c6\u89c9\u7b26\u53f7\n    likeBtn.textContent = likeBtn.classList.contains('liked') ? '&hearts;' : '\u2661';\n});<\/code><\/pre>\n<h3>2. Lightbox (\u5927\u56fe\u67e5\u770b)<\/h3>\n<p>\u903b\u8f91\u5f88\u7b80\u5355\uff1a\u70b9\u51fb\u56fe\u7247 -> \u83b7\u53d6 <code>src<\/code> -> \u8d4b\u7ed9\u906e\u7f69\u5c42\u91cc\u7684 <code>img<\/code> -> \u663e\u793a\u906e\u7f69\u5c42\u3002<\/p>\n<pre><code class=\"lang-javascript language-javascript javascript\">\/\/ \u70b9\u51fb\u6253\u5f00\nimageWrapper.addEventListener('click', (e) =&gt; {\n    e.stopPropagation();\n    lightboxImg.src = img.src;\n    lightbox.classList.add('active');\n    document.body.style.overflow = 'hidden'; \/\/ \u7981\u6b62\u80cc\u666f\u6eda\u52a8\n});\n\n\/\/ \u70b9\u51fb\u5173\u95ed (\u652f\u6301\u70b9\u51fb\u80cc\u666f\u3001\u5173\u95ed\u6309\u94ae\u3001ESC\u952e)\nconst closeLightbox = () =&gt; {\n    lightbox.classList.remove('active');\n    document.body.style.overflow = '';\n    \/\/ \u5ef6\u8fdf\u6e05\u7a7a src\uff0c\u9632\u6b62\u5173\u95ed\u52a8\u753b\u65f6\u56fe\u7247\u7a81\u7136\u6d88\u5931\n    setTimeout(() =&gt; { lightboxImg.src = ''; }, 300);\n}<\/code><\/pre>\n<hr \/>\n<h2>\u7ec6\u8282\u6253\u78e8\uff1a\u6df1\u8272\u6a21\u5f0f<\/h2>\n<p>\u4f5c\u4e3a\u4e00\u540d\u6ce8\u91cd\u4f53\u9a8c\u7684\u5f00\u53d1\u8005\uff0cDark Mode \u662f\u5fc5\u987b\u7684\u3002\u5229\u7528 <code>body.dark-mode<\/code> \u7c7b\u540d\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u91cd\u5199\u53d8\u91cf\u3002<\/p>\n<pre><code class=\"lang-css language-css css\">body.dark-mode .gallery-item {\n    background: #2a2a2a; \/* \u6df1\u7070\u80cc\u666f *\/\n    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);\n}\n\nbody.dark-mode .item-title {\n    color: rgba(255, 255, 255, 0.9);\n}<\/code><\/pre>\n<hr \/>\n<h2>\u6f14\u793a\u4ee3\u7801<\/h2>\n<p>\u4f60\u53ef\u4ee5\u76f4\u63a5\u628a\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801\u4fdd\u5b58\u4e3a <code>index.html<\/code> \u7136\u540e\u7528\u6d4f\u89c8\u5668\u6253\u5f00\uff01<\/p>\n<pre><code class=\"lang-html language-html html\">&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;zh-CN&quot;&gt;\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;\n\n&lt;title&gt;Miku Style Gallery Demo&lt;\/title&gt;\n\n&lt;style&gt;\n        \/* ================== \u57fa\u7840\u53d8\u91cf\u4e0e\u91cd\u7f6e ================== *\/\n        :root {\n            \/* \u521d\u97f3\u672a\u6765\u4e3b\u9898\u8272 *\/\n            --miku-color: #39c5bb;\n            --miku-color-rgb: 57, 197, 187;\n            --bg-color: #f5f7fa;\n            --text-color: #333;\n        }\n\n        body {\n            margin: 0;\n            padding: 0;\n            font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n            background-color: var(--bg-color);\n            color: var(--text-color);\n            transition: background-color 0.3s, color 0.3s;\n        }\n\n        \/* \u6f14\u793a\u7528\u7684\u6df1\u8272\u6a21\u5f0f\u5207\u6362\u6309\u94ae *\/\n        .theme-toggle {\n            position: fixed;\n            top: 20px;\n            right: 20px;\n            z-index: 100;\n            padding: 8px 16px;\n            background: var(--miku-color);\n            color: white;\n            border: none;\n            border-radius: 20px;\n            cursor: pointer;\n            box-shadow: 0 2px 10px rgba(57, 197, 187, 0.4);\n        }\n\n        \/* ================== \u4f60\u7684 Gallery CSS \u4ee3\u7801 ================== *\/\n\n        \/* \u7b80\u5316\u7248\u9876\u90e8\u6a2a\u5e45 *\/\n        .hero-banner-simple {\n            padding: 80px 20px 40px;\n            text-align: center;\n            background: linear-gradient(135deg, \n                rgba(var(--miku-color-rgb), 0.1) 0%, \n                rgba(var(--miku-color-rgb), 0.05) 100%);\n        }\n\n        .hero-content-simple {\n            max-width: 800px;\n            margin: 0 auto;\n        }\n\n        .hero-banner-simple .hero-title {\n            font-size: 3rem;\n            margin: 0 0 15px 0;\n            color: var(--text-color);\n        }\n\n        .hero-banner-simple .hero-subtitle {\n            font-size: 1.2rem;\n            color: #666;\n            margin: 0;\n            font-weight: 300;\n        }\n\n        \/* --- \u753b\u5eca\u5bb9\u5668 - \u591a\u5217\u7011\u5e03\u6d41\u5e03\u5c40 --- *\/\n        .gallery-container {\n            width: 100%;\n            max-width: 1400px;\n            margin: 0 auto;\n            padding: 20px 30px 80px;\n            box-sizing: border-box;\n\n            \/* \u591a\u5217\u5e03\u5c40 - \u7c7b\u4f3c\u7011\u5e03\u6d41\u6548\u679c *\/\n            column-count: 5;\n            column-gap: 16px;\n        }\n\n        \/* --- \u56fe\u7247\u5361\u7247\u6837\u5f0f --- *\/\n        .gallery-item {\n            break-inside: avoid;  \/* \u9632\u6b62\u5361\u7247\u88ab\u5206\u5272\u5230\u591a\u5217 *\/\n            margin-bottom: 16px;\n            border-radius: 16px;\n            overflow: hidden;\n            background: #fff;\n            cursor: pointer;\n            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);\n            transition: transform 0.3s ease, box-shadow 0.3s ease;\n        }\n\n        .gallery-item:hover {\n            transform: translateY(-4px);\n            box-shadow: 0 12px 30px rgba(57, 197, 187, 0.25);\n        }\n\n        \/* \u56fe\u7247\u5305\u88c5\u5668 *\/\n        .image-wrapper {\n            position: relative;\n            overflow: hidden;\n            border-radius: 16px 16px 0 0;\n            background-color: #eee; \/* \u56fe\u7247\u52a0\u8f7d\u524d\u7684\u5360\u4f4d\u8272 *\/\n        }\n\n        .gallery-item img {\n            width: 100%;\n            height: auto;  \/* \u4fdd\u6301\u56fe\u7247\u539f\u59cb\u6bd4\u4f8b *\/\n            display: block;\n            transition: transform 0.4s ease;\n        }\n\n        .gallery-item:hover img {\n            transform: scale(1.05);\n        }\n\n        \/* --- \u56fe\u7247\u4fe1\u606f\u533a\u57df\uff08\u6807\u9898 + \u7231\u5fc3\u6309\u94ae\uff09--- *\/\n        .item-info {\n            display: flex;\n            justify-content: space-between;\n            align-items: center;\n            padding: 12px 14px;\n            background: #fff;\n            transition: background 0.3s;\n        }\n\n        .item-title {\n            color: #333;\n            font-size: 13px;\n            font-weight: 500;\n            white-space: nowrap;\n            overflow: hidden;\n            text-overflow: ellipsis;\n            flex: 1;\n            margin-right: 10px;\n        }\n\n        \/* \u7231\u5fc3\u6309\u94ae *\/\n        .like-btn {\n            background: none;\n            border: none;\n            color: #ccc;\n            font-size: 18px;\n            cursor: pointer;\n            padding: 4px 8px;\n            transition: all 0.2s ease;\n            border-radius: 50%;\n        }\n\n        .like-btn:hover {\n            color: #ff6b9d;\n            transform: scale(1.15);\n        }\n\n        .like-btn.liked {\n            color: #ff6b9d;\n        }\n\n        \/* --- \u70b9\u51fb\u653e\u5927 (Lightbox) \u6837\u5f0f --- *\/\n        .lightbox {\n            position: fixed;\n            top: 0;\n            left: 0;\n            width: 100%;\n            height: 100%;\n            background: rgba(0, 0, 0, 0.92);\n            backdrop-filter: blur(8px);\n            display: none;\n            justify-content: center;\n            align-items: center;\n            z-index: 10000;\n            opacity: 0;\n            transition: opacity 0.3s ease;\n        }\n\n        .lightbox.active {\n            display: flex;\n            opacity: 1;\n        }\n\n        .lightbox img {\n            max-width: 90%;\n            max-height: 90%;\n            border-radius: 8px;\n            box-shadow: 0 0 20px rgba(57, 197, 187, 0.5);\n            transform: scale(0.9);\n            transition: transform 0.3s ease;\n        }\n\n        .lightbox.active img {\n            transform: scale(1);\n        }\n\n        .close-btn {\n            position: absolute;\n            top: 30px;\n            right: 40px;\n            color: white;\n            font-size: 40px;\n            cursor: pointer;\n            transition: color 0.3s, transform 0.3s;\n            z-index: 10001;\n            font-family: Arial, sans-serif;\n            line-height: 1;\n        }\n\n        .close-btn:hover {\n            transform: rotate(90deg);\n            color: var(--miku-color);\n        }\n\n        \/* ========== \u54cd\u5e94\u5f0f\u8bbe\u8ba1 ========== *\/\n        @media (min-width: 1200px) { .gallery-container { column-count: 5; } }\n        @media (min-width: 992px) and (max-width: 1199px) { .gallery-container { column-count: 4; } }\n        @media (min-width: 768px) and (max-width: 991px) { \n            .gallery-container { column-count: 3; padding: 20px 20px 60px; }\n            .hero-banner-simple .hero-title { font-size: 2.5rem; }\n        }\n        @media (min-width: 481px) and (max-width: 767px) { \n            .gallery-container { column-count: 2; column-gap: 12px; padding: 15px 15px 50px; }\n            .gallery-item { margin-bottom: 12px; border-radius: 12px; }\n        }\n        @media (max-width: 480px) { \n            .gallery-container { column-count: 2; column-gap: 10px; padding: 10px 10px 50px; }\n            .gallery-item { margin-bottom: 10px; border-radius: 10px; }\n        }\n\n        \/* ========== \u6df1\u8272\u6a21\u5f0f\u652f\u6301 ========== *\/\n        body.dark-mode {\n            --bg-color: #1a1a1a;\n            --text-color: #e0e0e0;\n        }\n\n        body.dark-mode .hero-banner-simple {\n            background: linear-gradient(135deg, \n                rgba(var(--miku-color-rgb), 0.15) 0%, \n                rgba(0, 0, 0, 0.1) 100%);\n        }\n\n        body.dark-mode .hero-banner-simple .hero-subtitle { color: #b0b0b0; }\n\n        body.dark-mode .gallery-item {\n            background: #2a2a2a;\n            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);\n        }\n\n        body.dark-mode .gallery-item:hover {\n            box-shadow: 0 12px 30px rgba(var(--miku-color-rgb), 0.4);\n        }\n\n        body.dark-mode .item-info { background: #2a2a2a; }\n        body.dark-mode .item-title { color: rgba(255, 255, 255, 0.9); }\n        body.dark-mode .like-btn { color: rgba(255, 255, 255, 0.5); }\n    &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n\n    &lt;button class=&quot;theme-toggle&quot; onclick=&quot;document.body.classList.toggle('dark-mode')&quot;&gt;\n        Toggle Dark Mode\n    &lt;\/button&gt;\n\n    &lt;div class=&quot;hero-banner-simple&quot;&gt;\n        &lt;div class=&quot;hero-content-simple&quot;&gt;\n            &lt;h1 class=&quot;hero-title&quot;&gt;Miku's Gallery&lt;\/h1&gt;\n            &lt;p class=&quot;hero-subtitle&quot;&gt;\u624b\u6413\u7011\u5e03\u6d41\u5e03\u5c40\u6f14\u793a (Pure CSS Masonry)&lt;\/p&gt;\n        &lt;\/div&gt;\n    &lt;\/div&gt;\n\n    &lt;div class=&quot;gallery-container&quot; id=&quot;gallery-container&quot;&gt;\n        &lt;\/div&gt;\n\n    &lt;div id=&quot;lightbox&quot; class=&quot;lightbox&quot;&gt;\n        &lt;span class=&quot;close-btn&quot;&gt;&amp;times;&lt;\/span&gt;\n        &lt;img id=&quot;lightbox-img&quot; src=&quot;&quot; alt=&quot;Full size preview&quot;&gt;\n    &lt;\/div&gt;\n\n&lt;script&gt;\n        \/\/ ================== 1. \u6a21\u62df\u6570\u636e\u751f\u6210 ==================\n        \/\/ \u4e3a\u4e86\u6f14\u793a\u65b9\u4fbf\uff0c\u6211\u4eec\u751f\u6210\u4e00\u4e9b\u968f\u673a\u9ad8\u5ea6\u7684\u56fe\u7247\u6570\u636e\n        const mockData = [\n            { h: 600, title: &quot;\u521d\u97f3\u672a\u6765 01&quot; },\n            { h: 400, title: &quot;\u8471\u8272\u53cc\u9a6c\u5c3e&quot; },\n            { h: 800, title: &quot;\u6f14\u5531\u4f1a\u73b0\u573a&quot; },\n            { h: 500, title: &quot;\u672a\u6765\u6709\u4f60&quot; },\n            { h: 700, title: &quot;\u9b54\u6cd5\u672a\u6765 2024&quot; },\n            { h: 450, title: &quot;\u96ea\u521d\u97f3&quot; },\n            { h: 650, title: &quot;\u6a31\u521d\u97f3&quot; },\n            { h: 550, title: &quot;\u8d5b\u8f66\u521d\u97f3&quot; },\n            { h: 300, title: &quot;Q\u7248 Miku&quot; },\n            { h: 750, title: &quot;Project DIVA&quot; },\n            { h: 400, title: &quot;Vocaloid&quot; },\n            { h: 600, title: &quot;39 Thanks&quot; },\n            { h: 500, title: &quot;\u7535\u5b50\u6b4c\u59ec&quot; },\n            { h: 850, title: &quot;World is Mine&quot; },\n            { h: 450, title: &quot;Tell Your World&quot; }\n        ];\n\n        const container = document.getElementById('gallery-container');\n\n        \/\/ \u6e32\u67d3 HTML\n        mockData.forEach((item, index) =&gt; {\n            \/\/ \u4f7f\u7528 placehold.co \u751f\u6210\u4e0d\u540c\u6bd4\u4f8b\u7684\u5360\u4f4d\u56fe\n            const imgSrc = `https:\/\/placehold.co\/400x${item.h}\/39c5bb\/ffffff?text=Miku+${index+1}`;\n\n            const html = `\n                &lt;div class=&quot;gallery-item&quot;&gt;\n                    &lt;div class=&quot;image-wrapper&quot;&gt;\n                        &lt;img src=&quot;${imgSrc}&quot; loading=&quot;lazy&quot; alt=&quot;${item.title}&quot;&gt;\n                    &lt;\/div&gt;\n                    &lt;div class=&quot;item-info&quot;&gt;\n                        &lt;span class=&quot;item-title&quot;&gt;${item.title}&lt;\/span&gt;\n                        &lt;button class=&quot;like-btn&quot;&gt;\u2661&lt;\/button&gt;\n                    &lt;\/div&gt;\n                &lt;\/div&gt;\n            `;\n            container.insertAdjacentHTML('beforeend', html);\n        });\n\n        \/\/ ================== 2. \u4f60\u7684 Gallery JS \u903b\u8f91 ==================\n        document.addEventListener('DOMContentLoaded', function() {\n            \/\/ \u83b7\u53d6\u5143\u7d20\n            const galleryItems = document.querySelectorAll('.gallery-item');\n            const lightbox = document.getElementById('lightbox');\n            const lightboxImg = document.getElementById('lightbox-img');\n            const closeBtn = document.querySelector('.close-btn');\n\n            if (!lightbox || !lightboxImg || !closeBtn) return;\n\n            \/\/ \u7ed9\u6bcf\u4e2a\u56fe\u7247\u5361\u7247\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6\n            galleryItems.forEach(item =&gt; {\n                const img = item.querySelector('img');\n                const imageWrapper = item.querySelector('.image-wrapper');\n                const likeBtn = item.querySelector('.like-btn');\n\n                \/\/ \u70b9\u51fb\u56fe\u7247\u533a\u57df -&gt; \u6253\u5f00\u5927\u56fe\n                if (imageWrapper &amp;&amp; img) {\n                    imageWrapper.addEventListener('click', (e) =&gt; {\n                        e.stopPropagation();\n                        lightboxImg.src = img.src;\n                        lightbox.classList.add('active');\n                        document.body.style.overflow = 'hidden';\n                    });\n                }\n\n                \/\/ \u70b9\u51fb\u7231\u5fc3\u6309\u94ae -&gt; \u5207\u6362\u559c\u6b22\u72b6\u6001\n                if (likeBtn) {\n                    likeBtn.addEventListener('click', (e) =&gt; {\n                        e.stopPropagation();\n                        likeBtn.classList.toggle('liked');\n                        if (likeBtn.classList.contains('liked')) {\n                            likeBtn.textContent = '&hearts;';\n                        } else {\n                            likeBtn.textContent = '\u2661';\n                        }\n                    });\n                }\n            });\n\n            \/\/ \u5173\u95ed\u529f\u80fd\u7684\u51fd\u6570\n            const closeLightbox = () =&gt; {\n                lightbox.classList.remove('active');\n                document.body.style.overflow = '';\n                setTimeout(() =&gt; { lightboxImg.src = ''; }, 300);\n            }\n\n            \/\/ \u70b9\u51fb\u5173\u95ed\u6309\u94ae\n            closeBtn.addEventListener('click', (e) =&gt; {\n                e.stopPropagation();\n                closeLightbox();\n            });\n\n            \/\/ \u70b9\u51fb\u9ed1\u8272\u80cc\u666f\u533a\u57df\u4e5f\u80fd\u5173\u95ed\n            lightbox.addEventListener('click', (e) =&gt; {\n                if (e.target === lightbox) {\n                    closeLightbox();\n                }\n            });\n\n            \/\/ \u6309 ESC \u952e\u5173\u95ed\n            document.addEventListener('keydown', (e) =&gt; {\n                if (e.key === 'Escape' &amp;&amp; lightbox.classList.contains('active')) {\n                    e.stopPropagation();\n                    closeLightbox();\n                }\n            });\n        });\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<hr \/>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u8fd9\u6b21\u91cd\u6784\uff0c\u6211\u4eec\u4e0d\u4ec5\u79fb\u9664\u4e86\u5916\u90e8\u4f9d\u8d56\uff0c\u8ba9\u9875\u9762\u52a0\u8f7d\u66f4\u5feb\uff0c\u8fd8\u5b8c\u5168\u638c\u63a7\u4e86\u5e03\u5c40\u7684\u6bcf\u4e00\u4e2a\u50cf\u7d20\u3002<\/p>\n<p><strong>\u6700\u7ec8\u6210\u679c\u7279\u70b9\uff1a<\/strong><\/p>\n<ul>\n<li><strong>CSS Only \u5e03\u5c40<\/strong>\uff1a\u5229\u7528 <code>column-count<\/code> \u5b9e\u73b0\u9ad8\u6027\u80fd\u7011\u5e03\u6d41\u3002<\/li>\n<li><strong>Zero Dependency<\/strong>\uff1a\u7eaf\u539f\u751f JS\uff0c\u65e0\u4efb\u4f55\u6846\u67b6\u8d1f\u62c5\u3002<\/li>\n<li><strong>Miku Style<\/strong>\uff1a\u4fdd\u7559\u4e86\u4e3b\u9898\u8272\u7684\u547c\u5438\u611f\u548c\u4ea4\u4e92\u7ec6\u8282\u3002<\/li>\n<\/ul>\n<p>\u5199\u4ee3\u7801\u6700\u5f00\u5fc3\u7684\u65f6\u523b\uff0c\u83ab\u8fc7\u4e8e\u770b\u7740\u81ea\u5df1\u624b\u6413\u7684\u529f\u80fd\u5b8c\u7f8e\u8fd0\u884c\u5728\u9875\u9762\u4e0a\u7684\u90a3\u4e00\u523b\u5440\uff01\u2728<\/p>","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u6700\u8fd1\u5728\u7f16\u5199\u6211\u7684web\u5927\u4f5c\u4e1a\u7684\u753b\u5eca\u9875\u9762\u3002\u6700\u5f00\u59cb\u662f\u628a\u56fe\u7247\u5f3a\u884c\u88c1\u526a\u6210\u6b63\u65b9\u5f62\uff0c\u611f\u89c9\u5931\u53bb\u4e86\u7075\u9b42\u3002 \u6211\u60f3\u8981\u4e00\u79cd\u50cf Pixiv \u6216 Pin &#8230;<\/p>","protected":false},"author":1,"featured_media":213,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[23],"tags":[],"class_list":["post-212","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web"],"_links":{"self":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/comments?post=212"}],"version-history":[{"count":4,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":218,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/212\/revisions\/218"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/media\/213"}],"wp:attachment":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/media?parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/categories?post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/tags?post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}