I want to pin something on my screen when the website first comes up and just have that pin stay in place forever, but the next elements will scroll over it. I'm completely new to ScrollTrigger -- was using ScrollMagic before -- so I'm a real newbie here. Here's what I have (below). I want #head1 to be pinned about 1/4 of the way down the screen and just stay there. What happens is, when I come to the website, #head1 is about a 1/4 of the way down the screen. When I scroll, #head1 jumps about 200px down and is unpinned. What am I doing wrong? (I have attached a codepen, but also being new to codepen, I don't know why my codepen isn't working.)
html:
<div class="screen" >
<img class="" id="tower" src="img/tower.jpg">
<div class="head1" id="head1">head1</div>
</div>
css:
.screen {
position: relative;
width: 100%;
height: 100vh;
margin-top: -2px;
clear: both;
}
#tower {
width: 100%;
position: absolute;
left: 0;
top: 0;
height: auto;
}
.head1 {
color: white;
font-family: 'Roboto', sans-serif;
font-size: 6rem;
font-weight: 600;
text-align: center;
}
jquery:
gsap.registerPlugin(ScrollTrigger);
$(document).ready(function() {
ScrollTrigger.create({
trigger: "#head1",
start: "top 200px",
pin: true
});
});