html点击复制功能

📚 新鲜出炉!我们的课程选择系统全新升级

👆 炫酷按钮效果,点击体验超赞

✨ 智能复制功能,一键获取课程代码

🎉 动感弹窗提醒,操作反馈即时呈现 科技感十足,yet简约直观!选课从未如此简单&有趣。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Copy</title>
</head>
<link rel="stylesheet" href="./text.css">
<body>
  <div id="popup" class="popup">复制成功!</div>
 <div class="a">
    <div class="list-a"></div>
<script>
const sum=[
  {
    "name": "计算机网络",
    "code": "24251.05129150-4.14"
  },
  {
    "name": "后端工程化技术实践",
    "code": "24251.28130130-1.5.03"
  },
  {
    "name": "软件工程",
    "code": "24251.28120350-3.21"
  },
  {
    "name": "NoSQL技术实践",
    "code": "24251.28130140-1.5.02"
  },
  {
    "name": "机器学习",
    "code": "24251.28120100-2.04"
  },
  {
    "name": "Web前端框架技术",
    "code": "24251.28130180-1.5.03"
  },
  {
    "name": "就业指导",
    "code": "24251.20010120-1.17"
  },
  {
    "name": "数据库原理与应用课程设计",
    "code": "24251.05139130-1.16"
  },
  {
    "name": "创新创业思维、创业模拟实训",
    "code": "24251.05139130-1.16"
  }
]  
copyStr=sum.map(item=>`<button onclick="myFunction('${item.code}')">${item.name}</button><br>`).join('')
document.querySelector('.list-a').innerHTML=copyStr
async function myFunction(text) {
  try {
    await navigator.clipboard.writeText(text);
    showPopup();
  } catch (err) {
    console.error('无法复制文本: ', err);
  }
}
function showPopup() {
            const popup = document.getElementById('popup');
            popup.classList.add('show');
            setTimeout(() => {
                popup.classList.remove('show');
            }, 2000);
        }
</script>
</div>
</body>
</html>

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    padding: 20px;
  }
  
  
  .container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    padding: 30px;
    max-width: 600px;
    width: 100%;
  }
  
  button {
    background: linear-gradient(45deg, #6a11cb 0%, #2575fc 100%);
    border: none;
    border-radius: 25px;
    color: white;
    cursor: pointer;
    font-size: 16px;
    margin: 10px 0;
    padding: 12px 20px;
    transition: all 0.3s ease;
    width: 100%;
    position: relative;
    overflow: hidden;
  }
  
  button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  }
  
  button:active {
    transform: translateY(1px);
  }
  
  button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
  }
  
  @keyframes ripple {
    0% {
      transform: scale(0, 0);
      opacity: 1;
    }
    20% {
      transform: scale(25, 25);
      opacity: 1;
    }
    100% {
      opacity: 0;
      transform: scale(40, 40);
    }
  }
  
  button:focus:not(:active)::after {
    animation: ripple 1s ease-out;
  }
 
.popup {
    position: fixed;
    top: -100px; /* Start off-screen */
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(145deg, #6b9c6f, #80bd9c);
    color: white;
    padding: 16px 24px;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2), 0 6px 6px rgba(0,0,0,0.1);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    font-size: 18px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    border: 2px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.popup::before {
    content: '✓';
    display: inline-block;
    margin-right: 10px;
    font-size: 22px;
    animation: pulse 2s infinite;
}

.popup.show {
    opacity: 1;
    top: 20px;
    animation: bounce 0.6s;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0) translateX(-50%);}
    40% {transform: translateY(-30px) translateX(-50%);}
    60% {transform: translateY(-15px) translateX(-50%);}
}

@keyframes pulse {
    0% {transform: scale(1);}
    50% {transform: scale(1.2);}
    100% {transform: scale(1);}
}

@media (prefers-reduced-motion: reduce) {
    .popup, .popup.show, .popup::before {
        animation: none;
        transition: opacity 0.5s ease;
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值