JSFiddle - React, Tailwind, and code Playground

by Dhanck

HTML

<header class="bg">
  <p style="width: 60%; margin-left: 20%; border-bottom: 1px solid #FFF; padding-bottom: 1em; margin-top:300px;">
    <span id="headerTitle">Joe Blow</span>
  </p>
</header>

CSS

.show {
  background-color: #000;
  width: 100%;
  height: 8.5em;
  opacity: 0.8;
}

#headerTitle {
  font-size: 2em;
   -webkit-transition: all 1s ease-in-out;
  -moz-transition: all 1s ease-in-out;
  -o-transition: all 1s ease-in-out;
  transition: all 1s ease-in-out;
}

JavaScript

$(window).scroll(function() {
  if ($(window).scrollTop() > 200) {
    $('.bg').addClass('show')
    $('#headerTitle').css("font-size", "1.5em");
  } else {
    $('.bg').removeClass('show')
    $('#headerTitle').css('font-size', "2em")
  }
});


$('.scroll').on('click', function(e) {
  e.preventDefault()

  $('html, body').animate({
    scrollTop: $(this.hash).offset().top
  }, 1000);
});