以下代码来自于国内直连GPT/Claude
1.鼠标移入红色圆圈,白色卡片过渡动画显示
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hover Card Animation</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="icon-container">
<div class="icon">⭐</div>
<div class="card">
<p>套餐:免费</p>
<ul>
<li>标准查询:36</li>
<li>高级查询:0</li>
<li>高级积分:0</li>
</ul>
<p>升级解锁专属特权:</p>
<ul>
<li>无限畅享 GPT-4</li>
<li>DALL-E 3 驱动的智能绘画</li>
<li>一键总结网页 & YouTube 视频</li>
<li>更多高级功能</li>
</ul>
</div>
</div>
</body>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f9f9f9;
}
.icon-container {
position: relative;
display: inline-block;
cursor: pointer;
}
.icon {
font-size: 30px;
background-color: #ffcc00;
padding: 10px;
border-radius: 50%;
text-align: center;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.card {
position: absolute;
top: -320px;
left: 50%;
transform: translateX(-50%);
width: 250px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
padding: 20px;
box-sizing: border-box;
}
.card p {
margin: 0 0 10px;
font-weight: bold;
}
.card ul {
list-style: none;
padding: 0;
margin: 0;
}
.card ul li {
margin: 5px 0;
}
.icon-container:hover .card {
opacity: 1;
visibility: visible;
transform: translateX(-50%) translateY(10px);
}
</style>
</html>
2.优化一下,当鼠标移动到卡片上时,卡片不要隐藏消失,并且增加结束过渡效果
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hover Card Animation</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="icon-container">
<div class="icon">⭐</div>
<div class="card">
<p>套餐:免费</p>
<ul>
<li>标准查询:36</li>
<li>高级查询:0</li>
<li>高级积分:0</li>
</ul>
<p>升级解锁专属特权:</p>
<ul>
<li>无限畅享 GPT-4</li>
<li>DALL-E 3 驱动的智能绘画</li>
<li>一键总结网页 & YouTube 视频</li>
<li>更多高级功能</li>
</ul>
</div>
</div>
</body>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f9f9f9;
}
.icon-container {
position: relative;
display: inline-block;
cursor: pointer;
}
.icon {
font-size: 30px;
background-color: #ffcc00;
padding: 10px;
border-radius: 50%;
text-align: center;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.card {
position: absolute;
top: 50px;
left: 50%;
transform: translateX(-50%) translateY(10px);
width: 250px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0s linear 0.3s;
padding: 20px;
box-sizing: border-box;
pointer-events: none; /* Prevent accidental interaction when hidden */
}
.card p {
margin: 0 0 10px;
font-weight: bold;
}
.card ul {
list-style: none;
padding: 0;
margin: 0;
}
.card ul li {
margin: 5px 0;
}
/* When hovering over icon or card */
.icon-container:hover .card,
.icon-container .card:hover {
opacity: 1;
visibility: visible;
transform: translateX(-50%) translateY(10px);
pointer-events: auto; /* Allow interaction when visible */
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0s;
}
/* When hiding the card */
.icon-container:not(:hover) .card {
opacity: 0;
visibility: hidden;
transform: translateX(-50%) translateY(0);
pointer-events: none;
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0s linear 0.3s;
}
</style>
</html>