Pen Settings



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


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


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.


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.


                <div class="wrapper">

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

      <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="" class="template-url">
                  <div class="article-thumb">
                    <img class="img-responsive template-image" alt="">
              <div class="col-md-6 col-sm-6">
                <div class="post-excerpt">
                  <h3 class="template-title">
                    <a href="" class="template-url"></a>
                  <div class="meta">
                    <span>by <a href="#" class="link template-author"></a></span>
                    <span class="template-date"></span>
                    <span class="comment template-comment"></span>
                  <p class="template-abstract"></p>
                  <a class="small-title rmore template-url">Read More</a>
          <!-- TEMPLATE END -->


.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 {
  color: #333;
}, 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;


// This data array could be loaded from an external file.
var myJSONarray = [
    url : "",
    image : "",
    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 : "",
    image : "",
    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 : "",
    image : "",
    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 : "",
    image : "",
    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 : "",
    image : "",
    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){

    // There is no more data in the array.
    // 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-comment").html('<i class="fa fa-comment-o"></i> '+myJSONarray[i].comments);
    // Remove the template class (which just hides).

    // Append to document.
  } // 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.


    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.
        notAllLoaded = false;
        console.log("Infinite scroll ended.");
    } // End scroll position check.
  } // End if all loaded check.
}); // End on scroll.