"change opacity on scroll jquery"
Bootstrap 4.1.1 Snippet by wikaws

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="header-bg"></div> <section> <h1>Prakash Prajapati</h1> <p> It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, conten making it look like readable English. Many desktop publishing packages and web page now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). <br><br> It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, conten making it look like readable English. Many desktop publishing packages and web page now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). <br><br> It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, conten making it look like readable English. Many desktop publishing packages and web page now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). <br><br> It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, conten making it look like readable English. Many desktop publishing packages and web page now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). <br><br> It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, conten making it look like readable English. Many desktop publishing packages and web page now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). <br><br> </p> <!--</section>--> <!--<script type="text/javascript">--> <!-- $(document).ready(function(){--> <!-- $(window).scroll(function() {--> <!-- alert("1");--> <!-- $(".header-bg").css("opacity", 1 - $(window) --> <!-- alert("2");--> <!-- scrollTop() / 100)--> <!-- });--> <!-- });--> <!--</script>-->
body { margin:0; padding:0; background:#000; font-family:sans-serif; } .header-bg { width:100%; height:100vh; background:url(https://www.planwallpaper.com/static/images/47141475-hd-wallpapers.jpg); background-size:cover; background-attachment:fixed; } section { padding:100px; width:100%; height:100vh; box-sizing:border-box; background:#000; } section h1 { margin:0 0 50px; padding:0; font-size:60px; text-align:center; color:#fff; } section p { font-size:20px; color:#fff; }
$(document).ready(function(){ $(window).scroll(function(){ $('.header-bg').css("opacity", 1 - $(window). scrollTop() / 700) }) });

Related: See More


Questions / Comments: