<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS3 iPhone锁屏解锁动画特效</title>
<style>
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #000;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
.lock-screen {
position: relative;
width: 320px;
height: 568px;
background-color: #000;
border-radius: 30px;
overflow: hidden;
box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}
.time {
position: absolute;
top: 100px;
left: 0;
right: 0;
text-align: center;
color: #fff;
font-size: 48px;
font-weight: 200;
}
.date {
position: absolute;
top: 160px;
left: 0;
right: 0;
text-align: center;
color: #fff;
font-size: 16px;
}
.slider-container {
position: absolute;
bottom: 100px;
left: 0;
right: 0;
text-align: center;
}
.slider {
width: 80px;
height: 80px;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 50%;
margin: 0 auto;
position: relative;
cursor: pointer;
}
.slider::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 30px;
height: 30px;
background-color: #fff;
border-radius: 50%;
}
.slider-animation {
animation: slide 1.5s ease-out forwards;
}
@keyframes slide {
0% {
transform: translateX(0);
}
50% {
transform: translateX(120px);
}
100% {
transform: translateX(0);
}
}
.water-drop {
position: absolute;
bottom: 100px;
left: 50%;
transform: translateX(-50%);
width: 80px;
height: 80px;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 50%;
opacity: 0;
animation: drop 1.5s ease-out forwards;
}
@keyframes drop {
0% {
transform: translateX(-50%) translateY(0);
opacity: 0;
}
20% {
opacity: 1;
}
80% {
opacity: 1;
}
100% {
transform: translateX(-50%) translateY(200px);
opacity: 0;
}
}
.website-link {
position: absolute;
bottom: 20px;
left: 0;
right: 0;
text-align: center;
color: rgba(255, 255, 255, 0.3);
font-size: 12px;
}
</style>
</head>
<body>
<div class="lock-screen">
<div class="time">9:41</div>
<div class="date">Monday, January 1</div>
<div class="slider-container">
<div class="slider" id="slider"></div>
<div class="water-drop" id="water-drop"></div>
</div>
<div class="website-link">
</div>
</div>
<script>
const slider = document.getElementById('slider');
const waterDrop = document.getElementById('water-drop');
slider.addEventListener('click', () => {
slider.classList.add('slider-animation');
waterDrop.style.opacity = '1';
waterDrop.style.animation = 'drop 1.5s ease-out forwards';
setTimeout(() => {
slider.classList.remove('slider-animation');
waterDrop.style.opacity = '0';
waterDrop.style.animation = '';
}, 1500);
});
</script>
</body>
</html>
CSS3实现iPhone锁屏解锁动画特效
360

被折叠的 条评论
为什么被折叠?



