#独家
首页悬浮广告窗口及活动窗口

2025-07-04 免费源码 0 187
郑重承诺丨精码云库提供安全交易、信息保真!
增值服务:
智优赋能
精研增效
匠心提质
智创升级
专精强基
解疑释难
0 码币
VIP折扣
    折扣详情
  • 体验VIP会员

    免费

  • 月卡VIP会员

    免费

  • 年卡VIP会员

    免费

  • 永久VIP会员

    免费

开通VIP尊享优惠特权
立即下载 升级会员 至尊广告位
详情介绍

源码介绍

  1. 现代美观的设计:使用了渐变色、圆角和阴影效果,创造出视觉层次感。
  2. 丰富的交互效果
    • 广告窗口加载后有浮动动画效果
    • 图片悬停时有放大效果
    • 按钮有悬停状态变化
    • 倒计时数字有脉冲动画
  3. 完整的功能实现
    • 倒计时功能显示活动剩余时间
    • 关闭按钮暂时隐藏广告,5 秒后重新显示
    • “不再显示” 按钮永久隐藏广告
  4. 响应式设计:广告窗口会根据屏幕尺寸自动调整大小,在移动设备上也能良好显示。

把下列源代码加入到首页中即可实现:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>精码云库5周年会员促销</title>
  <script src="https://cdn.tailwindcss.com"></script>
  <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="external nofollow"  rel="stylesheet">
  
  <script>
    tailwind.config = {
      theme: {
        extend: {
          colors: {
            primary: '#2563eb',
            secondary: '#1e40af',
            accent: '#f97316',
            dark: '#0f172a',
            light: '#f8fafc',
          },
          fontFamily: {
            inter: ['Inter', 'system-ui', 'sans-serif'],
          },
        },
      }
    }
  </script>
  
  <style type="text/tailwindcss">
    @layer utilities {
      .float-animation {
        animation: float 3s ease-in-out infinite;
      }
      .pulse-slow {
        animation: pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
      }
      .price-highlight {
        text-shadow: 0 0 8px rgba(249, 115, 22, 0.6);
      }
    }
    
    @keyframes float {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-10px); }
    }
  </style>
</head>
<body class="m-0 p-0 bg-gray-50 min-h-screen">
  <!-- 悬浮广告窗口 -->
  <div id="floatAd" class="fixed bottom-4 right-4 bg-white rounded-xl shadow-xl overflow-hidden transform transition-all duration-500 scale-100 z-50 w-[clamp(280px,30vw,400px)]">
    <!-- 广告头部 -->
    <div class="bg-gradient-to-r from-primary to-secondary text-white p-4">
      <div class="flex justify-between items-center">
        <h3 class="font-bold text-lg">精码云库5周年庆典</h3>
        <button id="closeAd" class="text-white hover:text-gray-200 transition-colors">
          <i class="fa fa-times text-xl"></i>
        </button>
      </div>
      <p class="text-blue-100 mt-1 text-sm">限时折扣,名额有限</p>
    </div>
    
    <!-- 广告内容 -->
    <div class="p-4">
      <div class="relative overflow-hidden rounded-lg mb-4">
        <img src="https://picsum.photos/seed/code/800/400" alt="精码云库5周年会员促销" class="w-full h-auto transform hover:scale-105 transition-transform duration-500">
        <div class="absolute top-2 left-2 bg-accent text-white text-xs font-bold px-2 py-1 rounded-full pulse-slow">
          限时5折
        </div>
      </div>
      
      <h4 class="font-semibold text-lg mb-2">会员限时折扣</h4>
      <p class="text-gray-600 mb-4">
        仅需<span class="text-accent font-bold text-xl price-highlight">198元</span>,
        畅享全站资源免费下载!进入高级会员群,
        尊享高级会员资格,享受全站年分红奖励
      </p>
      
      <div class="flex items-center text-sm text-gray-500 mb-4">
        <i class="fa fa-clock-o mr-2"></i>
        <span id="countdown" class="font-mono"></span>
      </div>
      
      <a href="https://www.jmkuc.com" target="_blank" class="w-full bg-accent hover:bg-orange-600 text-white font-bold py-3 px-4 rounded-lg transition-colors transform hover:scale-105 hover:shadow-lg flex items-center justify-center cursor-pointer">
        <i class="fa fa-rocket mr-2"></i>
        立即抢购,立省200元
      </a>
    </div>
    
    <!-- 广告底部 -->
    <div class="bg-gray-50 p-3 text-center text-xs text-gray-500">
      <button id="hideAd" class="text-gray-500 hover:text-gray-700 transition-colors">
        <i class="fa fa-eye-slash mr-1"></i> 不再显示
      </button>
    </div>
  </div>

  <script>
    // 倒计时功能
    function updateCountdown() {
      const endDate = new Date('2025-07-31T23:59:59').getTime();
      const now = new Date().getTime();
      const distance = endDate - now;
      
      const days = Math.floor(distance / (1000 * 60 * 60 * 24));
      const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
      const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
      const seconds = Math.floor((distance % (1000 * 60)) / 1000);
      
      document.getElementById('countdown').innerHTML = 
        `${days}天 ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
      
      if (distance < 0) {
        clearInterval(countdownTimer);
        document.getElementById('countdown').innerHTML = '活动已结束';
      }
    }
    
    // 初始更新倒计时
    updateCountdown();
    // 每秒更新一次
    const countdownTimer = setInterval(updateCountdown, 1000);
    
    // 关闭广告
    document.getElementById('closeAd').addEventListener('click', function() {
      const ad = document.getElementById('floatAd');
      ad.classList.remove('scale-100');
      ad.classList.add('scale-0');
      
      // 5秒后重新显示
      setTimeout(() => {
        ad.classList.remove('scale-0');
        ad.classList.add('scale-100', 'float-animation');
      }, 5000);
    });
    
    // 不再显示广告
    document.getElementById('hideAd').addEventListener('click', function() {
      const ad = document.getElementById('floatAd');
      ad.classList.remove('scale-100');
      ad.classList.add('scale-0');
      
      // 存储用户偏好
      localStorage.setItem('hideAd', 'true');
    });
    
    // 检查用户是否已选择不再显示广告
    document.addEventListener('DOMContentLoaded', function() {
      if (localStorage.getItem('hideAd') === 'true') {
        document.getElementById('floatAd').classList.add('scale-0');
      } else {
        // 页面加载完成后延迟显示广告
        setTimeout(() => {
          document.getElementById('floatAd').classList.add('float-animation');
        }, 2000);
      }
    });
  </script>
</body>
</html>
    

 

源码截图

首页悬浮广告窗口及活动窗口

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

精码云库 免费源码 首页悬浮广告窗口及活动窗口 https://www.jmkuc.com/1127.html

常见问题
  • 可能原因有:一是您的解压软件版本较低,不支持该压缩格式,建议更新解压软件至最新版;二是下载过程中文件损坏,您可尝试删除原文件,重新下载;若多次重新下载仍解压失败,可能是资源本身存在问题,请联系我们反馈,我们会尽快核实处理。
查看详情
  • 出现此情况,大概率是页面样式冲突所致。部分浏览器可能对某些 CSS 样式兼容性欠佳,当文章内复杂样式相互作用时,就可能导致布局异常。您可尝试刷新页面,若问题依旧,可切换到其他主流浏览器访问;或者检查您浏览器是否有安装可能干扰页面显示的插件,暂时禁用后再尝试浏览。
查看详情
  • 您可先在本站搜索栏输入相关关键词,筛选是否有对应源码的其他版本资源。若未找到,您可以通过 “问题反馈” 板块,向我们详细说明需求,包括文章名称、所需源码版本及用途等,我们会根据情况在后续资源整理中,优先为您补充相关版本资源。
查看详情
  • 可能是由于运行环境不匹配,如编程语言版本、依赖库缺失或版本不一致导致。您可先检查文章中是否有注明运行环境要求,按照要求配置;也可尝试在本站技术交流区搜索报错关键词,查看其他用户的解决方案;若仍无法解决,欢迎通过 “问题反馈” 提交报错信息和运行环境说明,我们将协助排查 。
查看详情

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务