设为首页收藏本站

 找回密码
 立即注册

只需一步,快速开始

搜索
热搜: Discuz WordPress
查看: 254|回復: 0

Wordpress的AeroCore主题站弹窗html代码

[複製鏈接]
  • TA的每日心情
    萌哒
    2026-2-6 13:52
  • 發表於 2026-4-2 21:18:01 | 顯示全部樓層 |閱讀模式
    这里说的就是老菜心的博客站,用的AeroCore主题,弹窗广告也是通过主题作者的一个WPOPT插件实现的


    直接输入文字也是可以的,只是太简朴了。支持html代码,那就来折腾下呗!去网上搜了个简单的代码,然后找DeepSeek做了美化。发现个问题是他不能识别插件自带的关闭按钮,也可能是我给他的信息不够专业,他没能找到原因。但更纠结的是他给的代码有关闭功能,但就是不能用。
    最后在不断的改进和摸索,总算是实现了这个功能,自我感觉还是不错的,虽然被我修改代码出来的效果不是那么专业,但我觉得还是能接受的,具体效果你们通过文章最后我上的博客站体验。代码如下:
    1. <!DOCTYPE html>
    2. <html lang="zh-CN">
    3. <head>
    4.     <meta charset="UTF-8">
    5.     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
    6.     <title>菜园叫车 | 无关闭按钮紧凑弹窗</title>
    7.     <style>
    8.         /* 卡片本身需要接收点击事件 */
    9.         .notice-card {
    10.             pointer-events: auto;
    11.         }

    12.         /* 弹窗卡片 - 响应式宽高,手机PC自适应 */
    13.         .notice-card {
    14.             max-width:px;
    15.             width: 100%;
    16.             background: #ffffff;
    17.             border-radius: 36px;
    18.             overflow: hidden;
    19.             box-shadow: 0 30px 50px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.02);
    20.             animation: fadeSlideUp 0.35s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    21.             position: relative;
    22.             transition: all 0.2s;
    23.         }

    24.         /* PC端适当缩小卡片最大宽度 */
    25.         @media (min-width: 768px) {
    26.             .notice-card {
    27.                 max-width: 460px;
    28.             }
    29.         }

    30.         /* ========= 图片区域 - 基础样式 ========= */
    31.         .img-wrapper {
    32.             width: 100%;
    33.             background: #f5f7fa;
    34.             display: flex;
    35.             justify-content: center;
    36.             align-items: center;
    37.             overflow: hidden;
    38.             line-height: 0;
    39.             max-height: 250px;
    40.         }
    41.         .img-wrapper img {
    42.             width: 100%;
    43.             height: auto;
    44.             max-height: 250px;
    45.             object-fit: cover;
    46.             display: block;
    47.         }

    48.         /* 手机端图片高度适配 */
    49.         @media (max-width: 560px) {
    50.             .img-wrapper {
    51.                 max-height: 430px;
    52.             }
    53.             .img-wrapper img {
    54.                 max-height: 230px;
    55.             }
    56.         }
    57.         @media (max-width: 400px) {
    58.             .img-wrapper {
    59.                 max-height: 115px;
    60.             }
    61.             .img-wrapper img {
    62.                 max-height: 115px;
    63.             }
    64.         }
    65.         
    66.         /* 横屏适配 */
    67.         @media (orientation: landscape) and (max-height: 500px) {
    68.             .img-wrapper {
    69.                 max-height: 90px;
    70.             }
    71.             .img-wrapper img {
    72.                 max-height: 90px;
    73.             }
    74.             .notice-card {
    75.                 max-height: 85vh;
    76.                 overflow-y: auto;
    77.             }
    78.         }

    79.         /* 内容区域 - 紧凑间距 */
    80.         .notice-content {
    81.             padding: 18px 22px 24px;
    82.             background: #ffffff;
    83.         }

    84.         @media (max-width: 560px) {
    85.             .notice-content {
    86.                 padding: 14px 18px 20px;
    87.             }
    88.         }
    89.         @media (min-width: 768px) {
    90.             .notice-content {
    91.                 padding: 16px 22px 22px;
    92.             }
    93.         }

    94.         /* 服务描述 */
    95.         .service-desc {
    96.             font-size: 15px;
    97.             line-height: 1.45;
    98.             color: #2c3e44;
    99.             margin-bottom: 12px;
    100.             font-weight: 440;
    101.             text-align: left;
    102.         }
    103.         @media (max-width: 560px) {
    104.             .service-desc {
    105.                 font-size: 13.8px;
    106.                 line-height: 1.42;
    107.             }
    108.         }
    109.         @media (min-width: 768px) {
    110.             .service-desc {
    111.                 font-size: 14.5px;
    112.             }
    113.         }

    114.         .service-desc strong {
    115.             color: #1f8a4c;
    116.             font-weight: 660;
    117.         }

    118.         .highlight-tag {
    119.             background: #e6f7ec;
    120.             padding: 2px 8px;
    121.             border-radius: 30px;
    122.             display: inline-block;
    123.             font-weight: 500;
    124.             font-size: 0.95em;
    125.         }

    126.         /* 微信联系方式 - 紧凑 */
    127.         .contact-highlight {
    128.             background: #eefaf2;
    129.             padding: 8px 14px;
    130.             border-radius: 24px;
    131.             margin: 12px 0 6px;
    132.             font-size: 13.5px;
    133.             color: #0c6b3f;
    134.             display: flex;
    135.             align-items: center;
    136.             gap: 8px;
    137.             flex-wrap: wrap;
    138.             font-weight: 500;
    139.             border-left: 3px solid #2ecc71;
    140.         }
    141.         @media (max-width: 560px) {
    142.             .contact-highlight {
    143.                 padding: 7px 12px;
    144.                 font-size: 12.5px;
    145.                 gap: 6px;
    146.             }
    147.         }
    148.         .contact-highlight span {
    149.             font-family: monospace;
    150.             font-size: 14px;
    151.             letter-spacing: 0.5px;
    152.             background: white;
    153.             padding: 3px 10px;
    154.             border-radius: 30px;
    155.             color: #166534;
    156.         }
    157.         @media (max-width: 560px) {
    158.             .contact-highlight span {
    159.                 font-size: 12px;
    160.                 padding: 2px 8px;
    161.             }
    162.         }

    163.         /* 主按钮 - 紧凑但醒目 */
    164.         .action-btn {
    165.             display: flex;
    166.             align-items: center;
    167.             justify-content: center;
    168.             gap: 6px;
    169.             font-weight: 600;
    170.             font-size: 16px;
    171.             line-height: 1.2;
    172.             padding: 12px 0;
    173.             margin: 16px auto 5px auto;
    174.             border-radius: 50px;
    175.             width: 100%;
    176.             background: linear-gradient(105deg, #227a44 0%, #24a05b 100%);
    177.             color: white;
    178.             text-decoration: none;
    179.             transition: all 0.22s;
    180.             box-shadow: 0 8px 16px -6px rgba(33, 150, 83, 0.35);
    181.             border: none;
    182.             cursor: pointer;
    183.             letter-spacing: 0.5px;
    184.         }
    185.         @media (max-width: 560px) {
    186.             .action-btn {
    187.                 font-size: 15px;
    188.                 padding: 10px 0;
    189.                 margin-top: 14px;
    190.             }
    191.         }
    192.         @media (min-width: 768px) {
    193.             .action-btn {
    194.                 font-size: 15px;
    195.                 padding: 11px 0;
    196.             }
    197.         }
    198.         .action-btn:active {
    199.             transform: scale(0.97);
    200.             box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    201.         }

    202.         .extra-tip {
    203.             text-align: center;
    204.             font-size: 10px;
    205.             color: #9aabb8;
    206.             margin-top: 12px;
    207.             display: flex;
    208.             justify-content: center;
    209.             gap: 8px;
    210.         }
    211.         @media (max-width: 560px) {
    212.             .extra-tip {
    213.                 font-size: 12px;
    214.                 margin-top: 20px;
    215.             }
    216.         }

    217.         /* 动画 */
    218.         @keyframes fadeSlideUp {
    219.             from {
    220.                 opacity: 0;
    221.                 transform: translateY(30px) scale(0.96);
    222.             }
    223.             to {
    224.                 opacity: 1;
    225.                 transform: translateY(0) scale(1);
    226.             }
    227.         }
    228.         .action-btn {
    229.             -webkit-tap-highlight-color: transparent;
    230.         }

    231.         /* PC端 hover 微效果 */
    232.         @media (hover: hover) {
    233.             .action-btn:hover {
    234.                 background: linear-gradient(105deg, #1c6e3e, #1e914b);
    235.                 box-shadow: 0 10px 20px -6px rgba(33, 150, 83, 0.45);
    236.             }
    237.         }
    238.         
    239.         /* 基础body布局 - 无蒙层 */
    240.         body {
    241.             overflow-y: auto;
    242.             margin: 0;
    243.             padding: 20px;
    244.             background: #f0f2f5;
    245.             display: flex;
    246.             align-items: center;
    247.             justify-content: center;
    248.             min-height: 100vh;
    249.             font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    250.         }
    251.         
    252.         /* 电脑端弹窗整体向上提高10px (保持之前调整) */
    253.         @media (min-width: 768px) {
    254.             body {
    255.                 align-items: flex-start;
    256.                 padding-top: 30px;   /* 原始padding 20px + 提高10px => 总30px */
    257.             }
    258.             .web_notice {
    259.                 margin-top: -10px;   /* 负边距向上偏移10px,实现弹窗整体提高效果 */
    260.             }
    261.             .notice-card {
    262.                 margin-bottom: 10px;
    263.             }
    264.         }
    265.         
    266.         /* 让弹窗居中显示 */
    267.         .web_notice {
    268.             display: flex;
    269.             align-items: center;
    270.             justify-content: center;
    271.             width: 100%;
    272.             max-width: 100%;
    273.         }
    274.     </style>
    275. </head>
    276. <body>
    277.     <!-- 无蒙层弹窗 - 无关闭按钮版本 -->
    278.     <div id="webNoticePopup" class="web_notice">
    279.         <div class="notice-card">
    280.             <!-- 图片区:电脑端图片高度缩短100px(基于之前增加一倍后再缩减100px,最终视觉合理)
    281.                  之前要求图片高度增加一倍 -> 原最大高度250px增倍至500px,现在电脑端缩短100px -> 最终400px
    282.                  移动端和横屏保持原增加一倍后的舒适高度不变,只调整PC端(≥768px)-->
    283.             <div class="img-wrapper pc-shorter-img">
    284.                 <img src="https://cgb.lucaixing.com/wp-content/uploads/2026/04/0fc6843e01d7a7a7e2c3c6584778733a.webp"
    285.                      alt="菜园叫车微型货车厢式开顶服务"
    286.                      loading="eager"
    287.                      class="responsive-img"
    288.                      onerror="this.onerror=null; this.src='https://picsum.photos/id/104/800/380?grayscale&seed=caiyuan';">
    289.             </div>
    290.             
    291.             <div class="notice-content">
    292.                 <div class="service-desc">
    293.                     🌿 <strong>菜园叫车</strong> 为您提供
    294.                     <span class="highlight-tag">微型货车(厢式/开顶)</span>
    295.                     专业送货服务,高效省心,支持城市配送、搬家拉货、大件运输。<br>
    296.                     欢迎联系 <strong style="background: #dcfce7; padding: 2px 8px; border-radius: 24px;">菜心哥微信</strong> 预约或咨询,感谢厚爱!
    297.                 </div>
    298.                
    299.                 <div class="contact-highlight">
    300.                     💚 微信直连 · 极速回复
    301.                     <span>Lucaixing2020</span>
    302.                     <span style="font-size:10px;">(推荐添加)</span>
    303.                 </div>
    304.                
    305.                 <a href="https://www.lucaixing.com/bbs/plugin.php?id=fn_weixinqun"
    306.                    class="action-btn"
    307.                    target="_blank"
    308.                    rel="nofollow noopener"
    309.                    id="confirmWechatBtn">
    310.                    ✅ 先加好友+菜心哥微信群
    311.                 </a>
    312.                 <div class="extra-tip">
    313.                     🔒 安全跳转 | 一键添加 | 货运专享
    314.                 </div>
    315.             </div>
    316.         </div>
    317.     </div>
    318.     <!-- 样式覆盖:实现电脑端图片高度缩短100px(从500px降至400px),同时保持手机端及横屏原始加倍效果不变,且整体弹窗位置向上10px保留 -->
    319.     <style>
    320.         /* 全局图片基础:手机/平板默认保持原先增加一倍后的高度(视觉舒适) */
    321.         .img-wrapper {
    322.             max-height: 500px;
    323.         }
    324.         .img-wrapper img {
    325.             max-height: 500px;
    326.             width: 100%;
    327.             height: auto;
    328.             object-fit: cover;
    329.         }
    330.         
    331.         /* 手机端 (宽度≤560px) 维持之前增加一倍后的高度(460px),确保移动端体验良好 */
    332.         @media (max-width: 560px) {
    333.             .img-wrapper {
    334.                 max-height: 460px !important;
    335.             }
    336.             .img-wrapper img {
    337.                 max-height: 460px !important;
    338.             }
    339.         }
    340.         @media (max-width: 400px) {
    341.             .img-wrapper {
    342.                 max-height: 230px !important;
    343.             }
    344.             .img-wrapper img {
    345.                 max-height: 230px !important;
    346.             }
    347.         }
    348.         
    349.         /* 电脑端 (宽度≥768px) 图片高度缩短100px: 原增加一倍后为500px,缩短100px后为400px */
    350.         @media (min-width: 768px) {
    351.             .img-wrapper {
    352.                 max-height: 400px !important;   /* 比500px减少100px,符合电脑端缩短要求 */
    353.             }
    354.             .img-wrapper img {
    355.                 max-height: 400px !important;
    356.                 object-fit: cover;
    357.             }
    358.         }
    359.         
    360.         /* 横屏场景特殊处理(维持原有比例但合理缩短以保证紧凑)
    361.            横屏时原本最大高度180px (原90px翻倍),电脑端横屏按比例同样微调,保持缩短趋势但不强制100px差值
    362.            由于横屏一般高度有限,缩短后维持视觉舒适,我们同样稍微降低20px让比例协调但不影响主体需求。
    363.            但是为了严格遵循“电脑端图片高度缩短100px”的要求且只在电脑断点生效,横屏中若宽度≥768时按400px规则即可覆盖。
    364.         */
    365.         @media (orientation: landscape) and (max-height: 500px) and (min-width: 768px) {
    366.             .img-wrapper {
    367.                 max-height: 300px !important;   /* 横屏大屏适度缩短,保持美观且遵守缩短精神 */
    368.             }
    369.             .img-wrapper img {
    370.                 max-height: 300px !important;
    371.             }
    372.         }
    373.         
    374.         /* 横屏手机尺寸(宽度<768)维持原来翻倍高度180px,不破坏移动体验 */
    375.         @media (orientation: landscape) and (max-height: 500px) and (max-width: 767px) {
    376.             .img-wrapper {
    377.                 max-height: 180px !important;
    378.             }
    379.             .img-wrapper img {
    380.                 max-height: 180px !important;
    381.             }
    382.         }
    383.         
    384.         /* 保留电脑端弹窗整体向上提高10px的调整 (已经实现) */
    385.         @media (min-width: 768px) {
    386.             body {
    387.                 align-items: flex-start;
    388.                 padding-top: 30px;
    389.             }
    390.             .web_notice {
    391.                 margin-top: -10px;
    392.             }
    393.             .notice-card {
    394.                 margin-bottom: 10px;
    395.             }
    396.         }
    397.         
    398.         /* 手机端保持居中且无偏移 */
    399.         @media (max-width: 767px) {
    400.             body {
    401.                 align-items: center;
    402.                 padding-top: 20px;
    403.             }
    404.             .web_notice {
    405.                 margin-top: 0;
    406.             }
    407.             .notice-card {
    408.                 margin-bottom: 0;
    409.             }
    410.         }
    411.         
    412.         /* 辅助样式:保证卡片在任何分辨率下不溢出 */
    413.         .notice-card {
    414.             margin-left: auto;
    415.             margin-right: auto;
    416.         }
    417.         
    418.         /* 确保无关闭按钮,无额外蒙层干扰 */
    419.         .web_notice {
    420.             pointer-events: auto;
    421.         }
    422.         
    423.         /* 对于高分辨率大屏也维持图片高度限制400px, 完全遵循缩短100px需求 */
    424.         @media (min-width: 1200px) {
    425.             .img-wrapper {
    426.                 max-height: 400px !important;
    427.             }
    428.             .img-wrapper img {
    429.                 max-height: 400px !important;
    430.             }
    431.         }
    432.         
    433.         /* 保持内容一致性,未改动任何文本与交互元素 */
    434.     </style>
    435. </body>
    436. </html>
    複製代碼
    PC端效果

    手机端效果

    有兴趣就来老菜心博客站体验:老菜心博客


    草根般深入探索与分享,就在我的菜园。
    回復

    使用道具 举报

    您需要登錄後才可以回帖 登录 | 立即注册  

    本版積分規則

    亲爱的,赶快加入我们吧!
    X
    获取帮助
    X

    客服咨询

    菜心哥 旺旺客服

    微博收听

    鹭彩星微博

    工作时间

    8:30 - 23:00

    QQ|Archiver|手机版|小黑屋|老菜心 ( 闽ICP备16022933号-1 )|网站地图

    GMT+8, 2026-4-11 12:26 , Processed in 0.031997 second(s), 37 queries .

    Powered by Lucaixing! X3.5 Licensed

    © 2001-2026 Discuz! Team.

    快速回复 返回顶部 返回列表