Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="app">
  <div class="cover-image">
    <div class="cover-image__overlay"></div>
    <div class="cover-image__text">
      <div class="cover-image__name">Taha Shashtari</div>
      <div class="cover-image__tweets">12K Tweets</div>
    </div>
    <img
      class="cover-image__image"
      src="https://images.unsplash.com/photo-1525547719571-a2d4ac8945e2?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80"
      alt=""
    />
  </div>
  <div class="header">
    <div class="header__content">
      <img
        src="https://tahazsh.com/images/taha.jpg"
        class="header__profile-image"
      />
      <div class="header__user">
        <h1 class="header__user-name">Taha Shashtari</h1>
        <span class="header__user-handle">@tahazsh</span>
      </div>

      <p class="header__bio">
        Hey everyone! I'm really excited to share this demo that I built. If you want to keep up with my latest work, feel free to follow me on Twitter <a href="https://twitter.com/tahazsh" rel="noopener noreferrer nofollow">@tahazsh</a>.
      </p>

      <div class="header__general-info">
        <div class="header__info-item">
          <svg
            class="header__info-icon"
            viewBox="0 0 24 24"
            aria-hidden="true"
            fill="currentColor"
          >
            <g>
              <path
                d="M12 7c-1.93 0-3.5 1.57-3.5 3.5S10.07 14 12 14s3.5-1.57 3.5-3.5S13.93 7 12 7zm0 5c-.827 0-1.5-.673-1.5-1.5S11.173 9 12 9s1.5.673 1.5 1.5S12.827 12 12 12zm0-10c-4.687 0-8.5 3.813-8.5 8.5 0 5.967 7.621 11.116 7.945 11.332l.555.37.555-.37c.324-.216 7.945-5.365 7.945-11.332C20.5 5.813 16.687 2 12 2zm0 17.77c-1.665-1.241-6.5-5.196-6.5-9.27C5.5 6.916 8.416 4 12 4s6.5 2.916 6.5 6.5c0 4.073-4.835 8.028-6.5 9.27z"
              ></path>
            </g>
          </svg>
          Internet
        </div>
        <div class="header__info-item">
          <svg
            class="header__info-icon"
            viewBox="0 0 24 24"
            aria-hidden="true"
            fill="currentColor"
          >
            <g>
              <path
                d="M7 4V3h2v1h6V3h2v1h1.5C19.89 4 21 5.12 21 6.5v12c0 1.38-1.11 2.5-2.5 2.5h-13C4.12 21 3 19.88 3 18.5v-12C3 5.12 4.12 4 5.5 4H7zm0 2H5.5c-.27 0-.5.22-.5.5v12c0 .28.23.5.5.5h13c.28 0 .5-.22.5-.5v-12c0-.28-.22-.5-.5-.5H17v1h-2V6H9v1H7V6zm0 6h2v-2H7v2zm0 4h2v-2H7v2zm4-4h2v-2h-2v2zm0 4h2v-2h-2v2zm4-4h2v-2h-2v2z"
              ></path>
            </g>
          </svg>

          Joined July 2011
        </div>
      </div>

      <div class="header__follow-info">
        <div class="header__follow-info-item">
          <span class="header__follow-number">100</span> Following
        </div>
        <div class="header__follow-info-item">
          <span class="header__follow-number">50K</span> Followers
        </div>
      </div>
    </div>
  </div>
  <div class="content">
    <div class="post">
      <div class="group">
        <div class="item item-128"></div>
        <div class="item item-96"></div>
        <div class="item item-full"></div>
      </div>
      <div class="group group-2">
        <div class="item item-full"></div>
        <div class="item item-full"></div>
        <div class="item item-96"></div>
      </div>
      <div class="group group-3">
        <div class="item item-full"></div>
        <div class="item item-320"></div>
        <div class="item item-full"></div>
      </div>

      <div class="group group-2">
        <div class="item item-full"></div>
        <div class="item item-full"></div>
        <div class="item item-96"></div>
      </div>
      <div class="group group-4">
        <div class="item item-128"></div>
        <div class="item item-96"></div>
        <div class="item item-full"></div>
      </div>
      <div class="group group-5">
        <div class="item item-full"></div>
        <div class="item item-320"></div>
        <div class="item item-full"></div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

:root {
  --background-color: hsl(208.7, 100%, 2%);

  background-color: var(--background-color);
}

body {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.app {
  max-width: 600px;
  min-height: 100vh;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
  display: flex;
  flex-direction: column;
}

.header {
  z-index: 2;
}

.header__content {
  padding: 0 16px;
}

.cover-image {
  width: 100%;
  height: 200px;
  overflow: hidden;
  position: sticky;
  top: 0;
  transform-origin: 0 0;
}

.cover-image__image {
  transform-origin: 0 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.cover-image__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
}

.cover-image__text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 0 10px 16px;
  z-index: 3;
  color: white;
  transform: translateY(80px);
  will-change: transform;
}

.cover-image__name {
  font-weight: bold;
  font-size: 16px;
}

.cover-image__tweets {
  font-size: 12px;
}

.header__profile-image {
  width: 130px;
  height: 130px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--background-color);
  transform: translateY(-50%);
  transform-origin: left bottom;
}

.header__user {
  margin-top: -60px;
}

.header__user-name {
  color: white;
  font-size: 20px;
  padding: 0;
  margin: 0;
}

.header__user-handle {
  color: #71767b;
  font-size: 15px;
  margin-top: 4px;
  display: block;
}

.header__bio {
  margin: 12px 0 0;
  color: white;
}

.header__bio a {
  color: rgb(29, 155, 240);
  text-decoration: none;
}

.header__general-info {
  margin: 12px 0 0;
  display: flex;
  align-items: center;
  gap: 0 12px;
}

.header__follow-info {
  margin: 12px 0 0;
  display: flex;
  align-items: center;
  gap: 0 20px;
  color: #71767b;
}

.header__follow-number {
  color: white;
}

.header__info-item {
  display: flex;
  align-items: center;
  color: #71767b;
  line-height: 1;
}

.header__info-icon {
  width: 18px;
  margin-right: 4px;
}

.content {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px 0;
}

.post {
  display: flex;
  flex-direction: column;
  max-width: 1024px;
  gap: 10px 0;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 16px;
}

.group {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0 8px;
}

.item {
  height: 15px;
  background-color: hsl(0, 0%, 25%);
  border-radius: 10px;
}

.item-128 {
  width: 128px;
}

.item-96 {
  width: 96px;
}

.item-320 {
  width: 320px;
}

.item-full {
  width: 100%;
}

.group-2 {
  padding-right: 50px;
}

.group-3 {
  padding-right: 150px;
}
.group-4 {
  padding-right: 100px;
}
.group-5 {
  padding-right: 200px;
}

              
            
!

JS

              
                const { ScrollObserver, valueAtPercentage } = aat

function addMorePosts() {
  const post = document.querySelector('.post')
  for (let i = 0; i < 8; i++) {
    const clonedPost = post.cloneNode(true)
    post.parentElement.appendChild(clonedPost)
  }
}

addMorePosts()

const coverImageHeight = 200
const targetImageHeight = 60
const header = document.querySelector('.header')
const coverImageContainer = document.querySelector('.cover-image')
const coverImageOverlay = document.querySelector('.cover-image__overlay')
const coverImageText = document.querySelector('.cover-image__text')
const profileImage = document.querySelector('.header__profile-image')
const headerUser = document.querySelector('.header__user')

ScrollObserver.Element(header, {
  offsetBottom: () => window.innerHeight - coverImageHeight,
  offsetTop: targetImageHeight
}).onScroll(({ percentageY }) => {
  const translateY = valueAtPercentage({
    from: 0,
    to: -(coverImageHeight - targetImageHeight),
    percentage: percentageY,
    unit: 'px'
  })
  const profileImageScale = valueAtPercentage({
    from: 1,
    to: 0.5,
    percentage: percentageY
  })
  coverImageContainer.style.transform = `translateY(${translateY})`
  profileImage.style.transform = `translateY(-50%) scale(${profileImageScale})`
  coverImageContainer.style.zIndex = percentageY >= 1 ? 10 : 1
})

ScrollObserver.Element(headerUser, {
  offsetBottom: () => window.innerHeight - targetImageHeight
}).onScroll(({ percentageY }) => {
  const translateY = valueAtPercentage({
    from: 42,
    to: 0,
    percentage: percentageY,
    unit: 'px'
  })
  coverImageOverlay.style.opacity = percentageY
  coverImageText.style.transform = `translateY(${translateY})`
})

              
            
!
999px

Console