위에서 아래로 내려오는 효과 6가지 정보
JavaScript 위에서 아래로 내려오는 효과 6가지
본문
1.gsap
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>gsap 사용</title>
<style>
.sample{background-color:yellow;}
</style>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/gsap.min.js"></script></head>
<body>
<div class="sample">
위에서 내려옵니다.
</div>
<script>
gsap.from(".sample", {y: -100,opacity:0, duration: 1});
</script>
</body>
</html>
2.gsap and timeline
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>gsap timeline 사용</title>
<style>
.sample{background-color:yellow;}
</style>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/gsap.min.js"></script></head>
<body>
<div class="sample">
위에서 내려옵니다.
</div>
<script>
const tl = gsap.timeline();
tl.from(".sample", {y: -100,opacity:0, duration: 1});
</script>
</body>
</html>
3.pure css
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>순수 CSS 애니메이션</title>
<style>
.sample {
background-color: yellow;
/* 애니메이션 설정 */
animation: slideDown 1s ease forwards;
}
/* 키프레임 정의 */
@keyframes slideDown {
from {
transform: translateY(-100px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
</style>
</head>
<body>
<div class="sample">
위에서 내려옵니다.
</div>
</body>
</html>
4.jquery animate
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>top 사용</title>
<style>
.sample{background-color:yellow;}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</head>
<body>
<div class="sample">
위에서 내려옵니다.
</div>
<script>
$(".sample")
.css({ position: "relative", top: "-100px", opacity: 0 })
.animate({ top: "0px", opacity: 1 }, 1000);
</script>
</body>
</html>
5.jquery.transit
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>jquery.transit 사용 https://github.com/rstacruz/jquery.transit</title>
<style>
.sample{background-color:yellow;}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.transit/0.9.12/jquery.transit.min.js"></script>
</head>
<body>
<div class="sample">
위에서 내려옵니다.
</div>
<script>
$(".sample")
.css({ position: "relative", translate: ['0','-100px'], opacity: 0 })
.transition({ translate: ['0','0'], opacity: 1 }, 1000);
</script>
</body>
</html>
6.Velocity
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Velocity 사용 https://github.com/julianshapiro/velocity</title>
<style>
.sample{background-color:yellow;}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.5.2/velocity.min.js"></script>
</head>
<body>
<div class="sample">
위에서 내려옵니다.
</div>
<script>
$(".sample")
.css({ position: "relative", top: "-100px", opacity: 0 })
.velocity({ top: "0px", opacity: 1 }, {duration: 1000});
</script>
</body>
</html>
추천
1
1
댓글 0개