Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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="wrapper">

  <div class="inner-content">
    <div class="container">
      <div class="section-head">
        <h2>Latest Bits</h2>
      </div>

      <div class="row">
        <div class="col-md-8 template-spot">

          <!-- TEMPLATE -->
          <article class="style2 template">
            <div class="row">
              <div class="col-md-6 col-sm-6">
                <a href="http://www.google.com" class="template-url">
                  <div class="article-thumb">
                    <img class="img-responsive template-image" alt="">
                  </div>
                </a>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="post-excerpt">
                  <h3 class="template-title">
                    <a href="http://www.google.com" class="template-url"></a>
                  </h3>
                  <div class="meta">
                    <span>by <a href="#" class="link template-author"></a></span>
                    <span class="template-date"></span>
                    <span class="comment template-comment"></span>
                  </div>
                  <p class="template-abstract"></p>
                  <a class="small-title rmore template-url">Read More</a>
                </div>
              </div>
            </div>
          </article>
          <!-- TEMPLATE END -->
          
        </div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                .template{
  display:none;
}
.wrapper {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.inner-content {
  padding: 50px 0 57px;
}

.container {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
}

.section-head {
  margin-bottom: 22px;
}

.section-head h2 {
  font-weight: 300;
}

article.style2 {
  padding-bottom: 30px;
  margin-bottom: 30px;
}

article {
  border-bottom: 1px solid #eeeeee;
  padding-bottom: 15px;
  margin-bottom: 30px;
}

article .article-thumb {
  position: relative;
  overflow: hidden;
  background: #fff;
}

article:hover .article-thumb {
  background: #000;
}

article .article-thumb img {
  width: 100%;
}

article .article-thumb img {
}

article .article-thumb:hover img {
}

article .post-excerpt {
  padding: 9px 0;
}

article .meta {
  margin-top: 2px;
}

.meta span {
  font-size: 14px;
  color: #787878;
}


a.link:hover, a {
  color: #333;
}

a.link, a:hover {
  color: #33ccff;
}

.small-title {
  font-size: 10px;
  letter-spacing: 0.10em;
  font-weight: bold;
  line-height: 18px;
  color: #333333;
  margin-bottom: 5px;
  text-transform: uppercase;
}
              
            
!

JS

              
                
// This data array could be loaded from an external file.
var myJSONarray = [
  {
    url : "http://www.google.com",
    image : "https://place-hold.it/370x231/5",
    title : "This is my first article",
    author : "Benjamin K.",
    date : "Sep 23, 2016",
    abstract : "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",
    comments : 1
  },{
    url : "https://learn.jquery.com/",
    image : "http://www.desartlab.com/wp-content/uploads/2015/10/jquery_logo.gif",
    title : "This is my first script!!!",
    author : "J. Q. Harry",
    date : "Dec 31, 2017",
    abstract : "You can do what you want, if you are a bit creative, my friend.",
    comments : 172
  },{
    url : "http://www.animalplanet.com/pets/cats/",
    image : "http://r.ddmcdn.com/s_f/o_1/cx_462/cy_245/cw_1349/ch_1349/w_720/APL/uploads/2015/06/caturday-shutterstock_149320799.jpg",
    title : "This is a cute cat.",
    author : "Miss Miew",
    date : "Dec 24, 2014",
    abstract : "You should care about cats, they are so nice.",
    comments : 20
  },{
    url : "http://dogtime.com/top-100-dog-names",
    image : "http://cdn1-www.dogtime.com/assets/uploads/2011/04/file_2153_column_popular-dog-names.jpg",
    title : "Hard time finding your dog name?",
    author : "Dr. Ballard",
    date : "Dec 25, 2016",
    abstract : "A dog name is what you will shout out loud outside to call him back home when it runs away... So think about it seriously!",
    comments : 34
  },{
    url : "https://secure.aspca.org/action/SAFE-Act-2017",
    image : "https://secure.aspca.org/files/aspca/social_images/advo-sideimage-us-horse-slaughter-safe-act-2015_062016_fb.jpg",
    title : "I love horse. How is it possible to hurt them?",
    author : "ASPCA",
    date : "Jan 1, 2018",
    abstract : "Save a horse... And get horse power!",
    comments : 52
  }
];


//===== Infinite scroll options !
// On page load, load article(s) from index 0 to...
var pageLoadUpTo = 1;
// How many article(s) to load when user reaches the page bottom.
var loadArticlesBy = 1;



// The article templating function.
function loadArticle(from,to){

  if(from>=myJSONarray.length){
    // There is no more data in the array.
    return;
  }
  if(to>=myJSONarray.length){
    // There is enought data to do a last loop... But "to" is too high.
    to = myJSONarray.length;
  }

  // Cloning loop.
  for(var i=from; i<to; i++){

    console.log("loaded article index #"+i);

    var clone = $(".template").clone();
    clone.find(".template-url").attr("href",myJSONarray[i].url);
    clone.find(".template-title").find("a").html(myJSONarray[i].title);
    clone.find(".template-image").attr("src",myJSONarray[i].image);
    clone.find(".template-author").html(myJSONarray[i].author);
    clone.find(".template-date").html(myJSONarray[i].date);
    clone.find(".template-abstract").html(myJSONarray[i].abstract);
    clone.find(".template-comment").html('<i class="fa fa-comment-o"></i> '+myJSONarray[i].comments);
    
    // Remove the template class (which just hides).
    clone.removeClass("template");

    // Append to document.
    $(".template-spot").append(clone);
    
  } // End cloning loop.
  
  // return the last index loaded.
  return i;
} // End templating function




// Execution on initial page load.
var loadedArticleNumber = loadArticle(0,pageLoadUpTo);

// Flag to stop the script when all loaded.
var notAllLoaded = true;

// The on scroll handler.
$(window).on("scroll",function(){

  if(notAllLoaded){

    var scrolledPosition = window.scrollY;
    var documentHeight = $(document).height();
    var viewport = $(window).innerHeight();
    var buffer = 2;

    // Check scrolled position versus page length.
    if(scrolledPosition > (documentHeight-viewport-buffer)){
      // Load articles
      var FROM = loadedArticleNumber;
      var TO = loadedArticleNumber+loadArticlesBy;

      // Load articles and retrieve the last index loaded.
      loadedArticleNumber = loadArticle(FROM,TO);

      // When all articles are loaded, toggle the flag in order to stop the script calling.
      if(typeof(loadedArticleNumber)=="undefined"){
        notAllLoaded = false;
        console.log("Infinite scroll ended.");
      }
    } // End scroll position check.
    
  } // End if all loaded check.
  
}); // End on scroll.
              
            
!
999px

Console