<section class="section">
  <h2>Scroll Down</h2>
</section>

<article class="post">
  <div class="container">

    <div class="post-content">
      <div class="post-details">
        <h1 class="post-title">An Awesome House</h1>
        <div class="post-desc">
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

          <p>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum
            qui dolorem eum fugiat quo voluptas nulla pariatur?</p>

          <p>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum
            qui dolorem eum fugiat quo voluptas nulla pariatur?</p>

          <p>Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus
            autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias
            consequatur aut perferendis doloribus asperiores repellat.</p>

          <p>On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue;
            and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of
            choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it
            will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures
            pains to avoid worse pains.</p>
        </div>
      </div>
      <aside class="post-sidebar">
        <div class="post-sidebar-inner">
          <div> Phone: <a href="tel:1234567890">
            1234567890
          </a>
          </div>
          <div>
            Email: <a href="mailto:info@house.com">
            info@house.com
          </a>
          </div>
          <div>
            Instagram: <a href="https://www.instagram.com/">your.name</a>
          </div>
        </div>
      </aside>
    </div>

  </div>
</article>

<section class="section section-bottom">
  <h2>That was a ScrollMagic Demo</h2>
</section>
* {
  padding: 0;
  margin: 0;
}

body {
  font: normal 18px/1.5 monospace;
}

.section {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: #ee3f3f;
  color: white;
  text-align: center;
}

/*PREVENT OVERLAPPING ON RESIZE*/
.section-bottom {
  position: relative;
  z-index: 2;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
}

.post {
  padding: 50px;
}

.post p + p {
  margin-top: 30px;
}

.post-desc {
  margin-top: 30px;
}

.post-details {
  background: whitesmoke;
}

.post-details,
.post-sidebar-inner  {
  padding: 30px;
}

.post-sidebar {
  margin-top: 20px;
}

.post-sidebar-inner {
  background: #aad7a3;
}

.post-sidebar div {
  font-weight: bold;
}

.post-sidebar div + div {
  margin-top: 10px;
}

.post-sidebar a {
  font-weight: normal;
  color: black;
  text-decoration: none;
}

@media screen and (min-width: 768px) {
  .post-content {
    display: grid;
    grid-gap: 20px;
    grid-template-columns: 70% 30%;
  }
  
  .post-sidebar {
    margin-top: 0;
  }
}
const postDetails = document.querySelector(".post-details");
const postSidebar = document.querySelector(".post-sidebar");
const postSidebarContent = document.querySelector(".post-sidebar > div");

const controller = new ScrollMagic.Controller();
const scene = new ScrollMagic.Scene({
  triggerElement: postSidebar,
  triggerHook: 0,
  duration: getDuration
}).addTo(controller);

if (window.matchMedia("(min-width: 768px)").matches) {
  scene.setPin(postSidebar, {pushFollowers: false});
}

// in your projects, you might want to debounce resize event for better performance
window.addEventListener("resize", () => {
  if (window.matchMedia("(min-width: 768px)").matches) {
    scene.setPin(postSidebar, {pushFollowers: false});
  } else {
    scene.removePin(postSidebar, true);
  }
});

function getDuration() {
  return postDetails.offsetHeight - postSidebarContent.offsetHeight;
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js