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 id="container">
	
</div>
              
            
!

CSS

              
                $color-background = #383141
$color-text = #FEFFFF
$color-primary = #F23650

*
	box-sizing border-box
	
body
	margin 0
	width 100%
	min-height 100vh
	background $color-background
	color $color-text
	
#container
	height 100%
	width 100%
	padding 2rem
	
	display flex
	flex-wrap wrap
	
.card
	background darken($color-background, 10)
	width 20rem
	padding 2rem
	margin 2rem
	
	display flex
	flex-direction column
	align-items center
	
.card-avatar
	width 5rem
	height 5rem
	object-fit cover
	border-radius 100%
              
            
!

JS

              
                const data = [
	{
		name: "Anna Komnene",
		avatar: "https://i.imgur.com/dE1Xhg4.png",
		description:
			'"The truth is all barbarians are usually fickle and by nature unable to keep their pledges."'
	},
	{
		name: "John the Grammarian",
		avatar: "https://i.imgur.com/8gQ4w2N.png",
		description:
			'"If you let fall from the same height two weights, one many times heavier than the other you will see that the ratio of the times required for the motion does not depend on the weights."'
	},
	{
		name: "Michael Psellos",
		avatar: "https://i.imgur.com/Zi92cPk.png",
		description:
			'"The Chronographia composed by the most learned and right honourable monk Michael, in which are recounted the deeds of the following Emperors..."'
	},
	{
		name: "Plethon",
		avatar: "https://i.imgur.com/0bmcLTq.png",
		description:
			'"Similarly, if one observes something irrational in nature, then the nature that accomplishes the work certainly does not lie therein; for nature is a divine institution and a divine institution cannot be irrational."'
	}
];

const $container = document.getElementById("container");

const createElement = ({ type, parent, attributes, children }) => {
	const elem = document.createElement(type);

	if (attributes) {
		Object.keys(attributes).forEach(key => elem.setAttribute(key, attributes[key]));
	}

	if (children) {
		children.forEach(child => {
			if (typeof child === "string") {
        const $textNode = document.createTextNode(child);
        elem.appendChild($textNode);
			} else if (typeof child === "object") {
				createElement({
					...child,
					parent: elem
				});
			}
		});
	}

	parent.appendChild(elem);
	return elem;
};

for (const each of data) {
	const $card = createElement({
		type: "div",
		parent: $container,
		attributes: { class: "card" },
		children: [
			{
				type: "img",
				attributes: {
					class: "card-avatar",
					src: each.avatar
				}
			},
			{
				type: "h2",
				attributes: { class: "card-title" },
				children: [each.name]
			},
			{
				type: "p",
				attributes: { class: "card-content" },
				children: [each.description]
			}
		]
	});
}

              
            
!
999px

Console