title: How to scrollIntoView target id element of href to center of page using jQuery
body: <p>I am curious how I can scroll the target id element of an anchor tag's href to the center of the page using the scrollIntoView method.</p>
  <p>Here is my code so far:</p>
  <pre><code>$(&quot;a&quot;).click(function () {
      var target = $($(this).attr(&quot;href&quot;));
    
      target[0].scrollIntoView({
        behavior: &quot;smooth&quot;, 
        block: &quot;center&quot;
      })
    });
  </code></pre>
  <p>I am able to log the targeted element to the console and use <a href="https://stackoverflow.com/questions/11785859/jquery-how-can-i-target-the-target-of-this">other methods</a> to change the targeted element but can't figure out how to center it when scrolling.</p>
  <p>Here is a <a href="https://codepen.io/choosegoose/pen/mdwqoWV" rel="nofollow noreferrer">Codepen</a> with an example of what I'd like to do but instead uses <code>scroll-margin-top: 50vh</code>.</p>
  <p>Anything is appreciated, Thx.</p>