JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<p>Minha opacidade é: <br> <span></span></p>
</div>
<div>
</div>
CSS
*{
margin: 0; padding: 0; border: 0; box-sizing: border-box;
}
div{
width: 100%;
background: #333;
height: 100vh;
position: relative;
}
div:nth-child(odd){
width: 100%;
background: #666;
height: 100vh;
}
div p{
display: block;
width: 100%;
font-size: 6vw;
text-align: center;
opacity: 0.7;
position: absolute;
line-height: 40px;
bottom: 10px;
color: #fff;
height: 100px;
}
JavaScript
$(document).on('scroll', function(){
var max = 0.7;
var opacity = max * (1 - $(this).scrollTop() / $(window).height());
$('div p').css('opacity', opacity);
$('div p span').html($('div p').css('opacity'));
})