0
我想讓頭部中的contnet放大並模糊,因爲您向下滾動。但我不希望它突然跳到模糊和放大。我希望它慢慢模糊和放大。我怎樣才能做到這一點?如何使用JavaScript進行動畫製作?
HTML:
<header class="top-section" id="top">
<div class="content">
<img src="assets/img/Logo.svg" alt="Logo">
<p>Scroll for more or <a href="">view my CV</a></p>
</div>
</header>
.top-section {
width: 100vw;
height: 100vh;
background-color: #0064b9;
}
.top-section .content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}
.top-section .content img {
max-width: 550px;
width: 80%;
}
.top-section .content p {
color: #fff;
padding-top: 10vh;
}
.top-section .content p a {
color: #fff;
transition: all 0.3s ease-in-out;
}
.top-section .content p a:hover {
color: #004bb7;
}
.blur {
zoom: 2;
filter: blur(20px);
-webkit-filter: blur(40px);
-ms-filter: blur(40px);
}
$(document).ready(function(){
$(window).scroll(function(e){
var size = $(this).scrollTop();
if(size > $(".content").offset().top){
$("p, img").addClass("blur");
}
else{
$("p, img").removeClass("blur");
}
})
})