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 is required to process package imports. If you need a different preprocessor remove all packages first.

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


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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


	<h1>Infinite Scroll + Pagination Experiment</h1>
	<p>After a poll by <a href="">@smashingmag</a>, <a href="">I got the idea to combine pagination and infinite scroll.</a> The former gives the user control, but needs more effort. The latter lacks control, but requires no special interaction.</p>
	<div class="article-list" id="article-list"></div>
	<ul class="article-list__pagination article-list__pagination--inactive" id="article-list-pagination"></ul>


                $animation-duration: .2s;

body {
	background-color: #f8f8f8;
	color: #333;
	counter-reset: page;
	-webkit-font-smoothing: antialiased;
	-moz-font-smoothing: grayscale;

h1, h2, h3, h4, h5, h6 {
	text-transform: uppercase;

a {
	$color: #28f;
	color: $color;
	text-decoration: none;
	&:hover, &:focus {
		color: darken($color, 15%);
	&:active {
		color: darken($color, 30%);

main {
	margin: 0 auto;
	max-width: 30em;
	padding: 1em;

.article-list__page {
	border-top: 1px solid #ddd;
	clear: both;
	counter-increment: page;
	padding-bottom: 3em;
	position: relative;
	&:before {
		background-color: #ddd;
		display: inline-block;
		content: counter(page);
		color: #888;
		padding: .25em .5em;
		position: absolute;
		left: calc(50% - .75em);
		top: -.75em;
		vertical-align: middle;
		z-index: 1;

.article-list__item {
	background-color: #eee;
	float: left;
	height: 15em;
	max-width: 50%;
	opacity: .75;
	transform: scale(.8);
	transition: opacity $animation-duration, transform $animation-duration;
	width: 15em;
	&:hover {
		opacity: 1;
		transform: scale(1);

.article-list__item__image {
	display: block;
	height: auto;
	margin: 0;
	opacity: 1;
	transition: opacity $animation-duration;
	width: 100%;

.article-list__item__image--loading {
	opacity: 0;

.article-list__pagination {
	background-color: #222;
	box-shadow: 0 0 1em rgba(#000, .25);
	display: block;
	bottom: 0;
	left: 0;
	list-style-type: none;
	margin: 0;
	padding: .5em;
	position: fixed;
	right: 0;
	text-align: center;
	transform: translateY(0);
	transition: transform $animation-duration;
	z-index: 2;

.article-list__pagination--inactive {
	transform: translateY(100%);

.article-list__pagination__item {
	display: inline-block;
	margin: 0 1em;
	a {
		$color: #888;
		color: $color;
		text-decoration: none;

		&:hover, &:focus {
			color: lighten($color, 15%);
		&:active {
			color: lighten($color, 30%);


                function getPageId(n) {
	return 'article-page-' + n;

function getDocumentHeight() {
	const body = document.body;
	const html = document.documentElement;
	return Math.max(
		body.scrollHeight, body.offsetHeight,
		html.clientHeight, html.scrollHeight, html.offsetHeight

function getScrollTop() {
	return (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;

function getArticleImage() {
	const hash = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
	const image = new Image;
	image.className = 'article-list__item__image article-list__item__image--loading';
	image.src = '' + hash;
	image.onload = function() {
	return image;

function getArticle() {
	const articleImage = getArticleImage();
	const article = document.createElement('article');
	article.className = 'article-list__item';
	return article;

function getArticlePage(page, articlesPerPage = 16) {
	const pageElement = document.createElement('div'); = getPageId(page);
	pageElement.className = 'article-list__page';
	while (articlesPerPage--) {
	return pageElement;

function addPaginationPage(page) {
	const pageLink = document.createElement('a');
	pageLink.href = '#' + getPageId(page);
	pageLink.innerHTML = page;
	const listItem = document.createElement('li');
	listItem.className = 'article-list__pagination__item';
	if (page === 2) {

function fetchPage(page) {

function addPage(page) {

const articleList = document.getElementById('article-list');
const articleListPagination = document.getElementById('article-list-pagination');
let page = 0;


window.onscroll = function() {
	if (getScrollTop() < getDocumentHeight() - window.innerHeight) return;