Use the css selector for the last two elements. Check out the sample code below:
<div id="demo">
<ul class="my-ul">
<li>First Element</li>
<li>Second Element</li>
<li>Third Element</li>
<li>Fourth Element</li>
<li>Fifth Element</li>
</ul>
</div>
.my-ul {
height: 90vh;
width: 40%;
background-color: grey;
}
li:last-child {
position: fixed;
top: 370px;
}
li:nth-child(4) {
position: fixed;
top: 350px;
}