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 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

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="btn">Click Me 1</div>
	<div class="btn">Click Me 2</div>
	<div class="btn">Click Me 3</div>
	<div class="btn">Click Me 4</div>
	<div class="btn">Click Me 5</div>
	<div class="btn">Click Me 6</div>
	<div class="btn">Click Me 7</div>
	<div class="btn">Click Me 8</div>
	<div class="btn">Click Me 9</div>
	<div class="btn">Click Me 10</div>
	<div class="btn">Click Me 11</div>
	<div class="btn">Click Me 12</div>
	<div class="btn">Click Me 13</div>
	<div class="btn">Click Me 14</div>
	<div class="btn">Click Me 15</div>
	<div class="btn">Click Me 16</div>
	<div class="btn">Click Me 17</div>
	<div class="btn">Click Me 18</div>
	<div class="btn">Click Me 19</div>
	<div class="btn">Click Me 20</div>
	<div class="btn">Click Me 21</div>
	<div class="btn">Click Me 22</div>
	<div class="btn">Click Me 23</div>
	<div class="btn">Click Me 24</div>
	<div class="btn">Click Me 25</div>
	<div class="btn">Click Me 26</div>
	<div class="btn">Click Me 27</div>
	<div class="btn">Click Me 28</div>
	<div class="btn">Click Me 29</div>
	<div class="btn">Click Me 30</div>
</div>



<button class="decorate">Convert to </br>pseudo-buttons</button>
              
            
!

CSS

              
                * {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	background-color: #545454;
	font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Tahoma, Roboto, Oxygen, Ubuntu, Cantarell,
        "Fira Sans", "Open Sans", sans-serif;
}

.wrapper {
	max-width: 1200px;
	width: 80%;
	margin: 0 auto;
}

.btn {
	font-size: 1em;
	color: #dcdcdc;
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	min-height: 45px;
	padding: 0 10px;
	border-radius: 2px;
	border: 1px solid #b5b5b5;
	background-color: #616161;
	margin: 2px;
	&:focus {
		border: 1px solid white;
		outline: 0;
	}
	&[aria-pressed="true"] {
		background-color: #e4e4e4;
		color: #137a5a;
	}
}

.decorate {
	position: fixed;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	height: 50px;
	font-size: 1em;
	width: 200px;
}
              
            
!

JS

              
                // Are the btns decorated of not
let decorated = false;

// Grab the button to decorate
var decorate = document.querySelector("button.decorate");
// Grab wrapper
var wrapper = document.querySelector(".wrapper");

// Handle action on the decorate btn
decorate.addEventListener("click", e => {
	decorateBtns();
});

function decorateBtns() {
	if (decorated) {
		return;
	}
	// Grab btns
	let btns = document.querySelectorAll(".btn");
	// decorate them
	btns.forEach((btn, idx) => {
		btn.setAttribute("role", "button");
		btn.setAttribute("aria-pressed", "false");
		btn.setAttribute("tabindex", "0");
	});
	// You don't get keyboard handler by default on converted btns: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#Required_JavaScript_Features
	wrapper.addEventListener("keydown", e => {
			if (e.key === " " || e.key === "Enter" || e.key === "Spacebar") {
				toggleBtn(e.target);
			}
		});
	decorated = true;
}

function toggleBtn(ele) {
	ele.setAttribute(
		"aria-pressed",
		ele.getAttribute("aria-pressed") === "true" ? "false" : "true"
	);
}

              
            
!
999px

Console