2021 Image Zoom In on Scroll and Load Article | Css Code Fun

Image Zoom In on Scroll and Load Article | Css Code Fun

Hero Image Zoom In On Scroll And Load Article css tricks for a predefined area in each slide css code fun.

If you are looking to give some visual flair for the hero image in you next article then you can try out this zoom in effect designed by Vail Joy. When you scroll down the image zooms in and the article content moves in from the bottom of the page.

If you are having trouble with the pen, try the archived copy on GitHub

Check out the tutorial on Web Designer Wall

Hero image in Gif: RIO from Dribbble

HTML Snippets for Hero Image Zoom In on Scroll and Load Article css code fun

<header class="zoom">
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/927610/pexels-photo-587409.jpeg">
</header>
<main role="main">
  <div class="content">
    <h1>Zoom Hero Image on Scroll</h1>
     <a href="http://webdesignerwall.com/tutorials/how-to-add-icon-fonts-to-any-element-with-css" alt="webdesignerwall.com" target="_blank">View Tutorial</a>
    <p>Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Maecenas sed diam eget risus varius blandit sit amet non magna. Nulla vitae elit libero, a pharetra augue. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</p>
    <p>Curabitur blandit tempus porttitor. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>   
    <footer>
<p>A <a href="http://www.webdeisgnerwall.com" alt="web designer wall" target="_blank">webdesignerwall.com</a> Tutorial</p>
</footer>
  </div>
  
</main>

Css Snippet css code fun | Image Zoom In on Scroll

/* --- General Pen Styles --- */
body{
  font-family: Georgia, serif;
  color: #333;
  font-size: 1.4rem;
  line-height: 2rem;
}
a{color: #000;}
h1{
  font-size: 2.6rem;
  line-height: 2.6rem;
}
.content{
  margin: 0 auto;
  max-width: 90%;
  width: 720px;
}
main{
  padding: 1% 0;
  position: relative;
  background: #f5f5f5;
  box-shadow: 0px -10px 60px rgba(0,0,0,0.25);
    height: 100%;
}
footer p{
  font-size: .8rem;
  font-weight: bold;
  color: #ccc;
}
footer a{color: #ccc;}
/* --- Important Pen Styles --- */

.zoom{
  overflow: hidden;
  padding-bottom: 55%;
}
.zoom img{
  position: fixed;
  top: 0%;
  left: 50%;
  max-width: 200%;
  width: 100%;
  transform: translateX(-50%);
  /* Thanks  @bastian_fiessinger. Use when activating blur effect:
  will-change: -webkit-filter, filter, transform; */
}
@media (max-width: 667px) {
  h1{
    font-size: 1.8rem;
    line-height: 2.6rem;
    text-align: left;
  }
  .content{
    margin: 0 auto;
    max-width: 90%;
    width: 100%;
    height: 100%;
    text-align: justify;
  }
  .zoom{
    overflow: hidden;
    padding-bottom: 75%;
  }

}

JS Snippet

$(window).scroll(function() {
  var scroll = $(window).scrollTop();
  $(".zoom img").css({
    transform: 'translate3d(-50%, -'+(scroll/100)+'%, 0) scale('+(100 + scroll/5)/100+')',
    //Blur suggestion from @janwagner: https://codepen.io/janwagner/ in comments
    //"-webkit-filter": "blur(" + (scroll/200) + "px)",
    //filter: "blur(" + (scroll/200) + "px)"
  });
});

 

Add a Comment

Your email address will not be published. Required fields are marked *