🌈 CSS 每日一练
🎨 渐变色按钮
.btn-gradient {
background: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%);
border: none;
color: white;
padding: 12px 24px;
border-radius: 30px;
font-weight: bold;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
transition: all 0.3s ease;
}
.btn-gradient:hover {
transform: translateY(-3px);
box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
✨ 卡片悬停效果
.card {
width: 300px;
background: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
transition: transform 0.5s ease;
}
.card:hover {
transform: translateY(-10px) rotate(2deg);
}
.card-img {
height: 200px;
object-fit: cover;
transition: transform 0.5s ease;
}
.card:hover .card-img {
transform: scale(1.1);
}
🌟 文字流光效果
.text-shine {
font-size: 3rem;
background: linear-gradient(90deg, #ff4d4d, #f9cb28, #ff4d4d);
background-size: 200% auto;
color: transparent;
-webkit-background-clip: text;
background-clip: text;
animation: shine 3s linear infinite;
}
@keyframes shine {
to {
background-position: 200% center;
}
}
🍃 呼吸灯效果
.breathing-light {
width: 50px;
height: 50px;
border-radius: 50%;
background: #4facfe;
box-shadow: 0 0 10px #4facfe;
animation: breathing 3s ease-in-out infinite;
}
@keyframes breathing {
0%, 100% {
transform: scale(1);
opacity: 0.8;
}
50% {
transform: scale(1.2);
opacity: 1;
box-shadow: 0 0 20px #4facfe;
}
}
🌀 3D旋转立方体
.cube-container {
perspective: 1000px;
width: 200px;
height: 200px;
}
.cube {
width: 100%;
height: 100%;
position: relative;
transform-style: preserve-3d;
animation: spin 10s infinite linear;
}
.cube-face {
position: absolute;
width: 200px;
height: 200px;
opacity: 0.8;
display: flex;
align-items: center;
justify-content: center;
font-size: 2rem;
color: white;
}
.front { transform: rotateY(0deg) translateZ(100px); background: #ff5e62; }
.back { transform: rotateY(180deg) translateZ(100px); background: #4facfe; }
.right { transform: rotateY(90deg) translateZ(100px); background: #a6c1ee; }
.left { transform: rotateY(-90deg) translateZ(100px); background: #fbc2eb; }
.top { transform: rotateX(90deg) translateZ(100px); background: #84fab0; }
.bottom { transform: rotateX(-90deg) translateZ(100px); background: #8fd3f4; }
@keyframes spin {
from { transform: rotateX(0) rotateY(0); }
to { transform: rotateX(360deg) rotateY(360deg); }
}
这一切,似未曾拥有