<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS3分享图标按钮过渡动画特效</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #f5f5f5;
font-family: 'Arial', sans-serif;
}
.container {
text-align: center;
padding: 30px;
}
h1 {
margin-bottom: 40px;
color: #333;
}
.share-container {
position: relative;
display: inline-block;
margin: 0 15px;
}
.share-button {
width: 60px;
height: 60px;
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
position: relative;
z-index: 10;
transition: all 0.3s ease;
}
.share-button:hover {
transform: scale(1.1);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}
.share-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 24px;
height: 24px;
transition: all 0.3s ease;
}
.share-icon::before,
.share-icon::after {
content: '';
position: absolute;
background: white;
transition: all 0.3s ease;
}
.share-icon::before {
top: 0;
left: 50%;
width: 2px;
height: 100%;
margin-left: -1px;
}
.share-icon::after {
top: 50%;
left: 0;
width: 100%;
height: 2px;
margin-top: -1px;
}
.share-button:hover .share-icon::before {
transform: rotate(90deg);
}
.share-button:hover .share-icon::after {
transform: rotate(180deg);
}
.share-options {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 60px;
height: 60px;
border-radius: 50%;
background: white;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
z-index: 5;
opacity: 0;
transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.share-button:hover ~ .share-options {
opacity: 1;
width: 240px;
height: 60px;
border-radius: 30px;
}
.share-option {
position: absolute;
width: 40px;
height: 40px;
background: #f5f5f5;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
top: 10px;
left: 10px;
opacity: 0;
transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
transform: translateY(10px);
cursor: pointer;
}
.share-button:hover ~ .share-options .share-option {
opacity: 1;
transform: translateY(0);
}
.share-option:nth-child(1) {
left: 15px;
transition-delay: 0.1s;
background: #3b5998;
color: white;
}
.share-option:nth-child(2) {
left: 65px;
transition-delay: 0.2s;
background: #1da1f2;
color: white;
}
.share-option:nth-child(3) {
left: 115px;
transition-delay: 0.3s;
background: #dd4b39;
color: white;
}
.share-option:nth-child(4) {
left: 165px;
transition-delay: 0.4s;
background: #0077b5;
color: white;
}
.share-option i {
font-size: 18px;
}
.credit {
position: fixed;
bottom: 20px;
right: 20px;
color: #666;
font-size: 14px;
}
.credit a {
color: #4facfe;
text-decoration: none;
}
/* 响应式设计 */
@media (max-width: 600px) {
.share-button:hover ~ .share-options {
width: 180px;
}
.share-option:nth-child(4) {
display: none;
}
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>
<body>
<div class="container">
<h1>CSS3分享按钮动画特效</h1>
<div class="share-container">
<button class="share-button">
<span class="share-icon"></span>
</button>
<div class="share-options">
<div class="share-option">
<i class="fab fa-facebook-f"></i>
</div>
<div class="share-option">
<i class="fab fa-twitter"></i>
</div>
<div class="share-option">
<i class="fab fa-google"></i>
</div>
<div class="share-option">
<i class="fab fa-linkedin-in"></i>
</div>
</div>
</div>
</div>
</body>
</html>
CSS3分享图标按钮过渡动画特效
于 2025-06-09 18:02:01 首次发布