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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

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.

              <h3>Select text in the paragraphs below and see a pop-up menu.</h3>
 <h1>The Hart and the Hunter</h1>
 <p>The Hart was once drinking from a pool and admiring the noble figure he made there.</p>
 <p>“Ah,” said he, “where can you see such noble horns as these, with such antlers! I wish I had legs more worthy to bear such a noble crown; it is a pity they are so slim and slight.”</p>
 <p>At that moment a Hunter approached and sent an arrow whistling after him.</p>
 <p>Away bounded the Hart, and soon, by the aid of his nimble legs, was nearly out of sight of the Hunter; but not noticing where he was going, he passed under some trees with branches growing low down in which his antlers were caught, so that the Hunter
  had time to come up.</p>
 <p>“Alas! alas!” cried the Hart: “We Often Despise What Is Most Useful To Us.”</p>
<template id="shareBoxTemplate"><span id="shareBox"><button></button></span></template>
              #shareBox {
    width: 30px;
    height: 30px;
    position: absolute;
#shareBox > button {
    width: 100%;
    height: 100%;
    background-color: #292A2B;
    border: none;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    background-image: url("https://raw.githubusercontent.com/hongkiat/selected-text-action-menu/gh-pages/twitter.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 70%;
#shareBox > button::after {
	position: absolute;
	content: '';
	border-top: 10px solid #292A2B;
	border-left:10px solid transparent;
	border-right: 10px solid transparent;
	left: 5px;
	top: 30px;	
  width: 400px;
  margin: auto;
  font-size: 14pt;
  text-align: center;
  background-color: teal;
  color: white;
  padding: 5px 0;
  font-weight: 400;
              document.addEventListener('mousedown', onMouseDown);
document.addEventListener('mouseup', onMouseUp);
var temp = document.querySelector('#shareBoxTemplate');

function onMouseDown() {
	var shareBox = document.querySelector('#shareBox');
	if (shareBox !== null)

function onMouseUp() {
	var sel = document.getSelection(),
		txt = sel.toString();
	if (txt !== "") {
		var range = sel.getRangeAt(0);
		if (range.startContainer.parentElement.parentElement.localName === "article" || range.startContainer.parentElement.localName === "article") {
			document.body.insertBefore(document.importNode(temp.content, true), temp);
			var rect = range.getBoundingClientRect();
			var shareBox = document.querySelector('#shareBox');
			shareBox.style.top = `calc(${rect.top}px - 38px)`;
			shareBox.style.left = `calc(${rect.left}px + calc(${rect.width}px / 2) - 30px)`;
			var shareBtn = shareBox.querySelector('button');
			shareBtn['shareTxt'] = txt;
			shareBtn.addEventListener('mousedown', onShareClick, true);

function onShareClick() {
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.