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 class="tabs-accordion">
	<div class="action-group">
		<div class="tab" data-tab="0">
			<p>Label One</p>
		</div>
		<div class="tab" data-tab="1">
			<p>Label Two</p>
		</div>
		<div class="tab" data-tab="2">
			<p>Label Three</p>
		</div>
		<div class="tab" data-tab="3">
			<p>Label Four</p>
		</div>
		<div class="action-content">
			Space, the final frontier. These are the voyages of the Starship Enterprise. Its five-year mission: to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before. Many say exploration is part of our destiny, but it’s actually our duty to future generations and their quest to ensure the survival of the human species.
		</div>
		<div class="action-content action-content-hide">
			Just say anything, George, say what ever's natural, the first thing that comes to your mind. Take that you mutated son-of-a-bitch. My pine, why you. You space bastard, you killed a pine. You do? Yeah, it's 8:00. Hey, McFly, I thought I told you never to come in here. Well it's gonna cost you. How much money you got on you?
		</div>
		<div class="action-content action-content-hide">
			Cupcake ipsum dolor. Sit amet marshmallow topping cheesecake muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly beans topping carrot cake danish tart cake cheesecake. Muffin danish chocolate soufflé pastry icing bonbon oat cake. Powder cake jujubes oat cake. Lemon drops tootsie roll marshmallow halvah carrot cake.
		</div>
		<div class="action-content action-content-hide">
			Bacon ipsum dolor amet short ribs brisket venison rump drumstick pig sausage prosciutto chicken spare ribs salami picanha doner. Kevin capicola sausage, buffalo bresaola venison turkey shoulder picanha ham pork tri-tip meatball meatloaf ribeye. Doner spare ribs andouille bacon sausage. Ground round jerky brisket pastrami shank.
		</div>
	</div>
</div>
              
            
!

CSS

              
                html,
body {
	margin: 0;
}
.tabs-accordion {
	font: normal 12pt/23px "Arial";
	max-width: 700px;
	margin: 20px auto;
	display: flex;
	position: relative;
}
.tabs-accordion p {
	margin: 0;
}
.action-group {
	width: 100%;
	display: grid;
	background-color: lightgrey;
	grid-template-areas:
		"tabOne tabTwo tabThree tabFour"
		"contentOne contentTwo contentThree contentFour";
}
.action-group > div:nth-child(1) {
	grid-area: tabOne;
}
.action-group > div:nth-child(2) {
	grid-area: tabTwo;
}
.action-group > div:nth-child(3) {
	grid-area: tabThree;
}
.action-group > div:nth-child(4) {
	grid-area: tabFour;
}
.action-group > div:nth-child(5) {
	grid-area: contentOne;
}
.action-group > div:nth-child(6) {
	grid-area: contentTwo;
}
.action-group > div:nth-child(7) {
	grid-area: contentThree;
}
.action-group > div:nth-child(8) {
	grid-area: contentFour;
}
.action-group > div:nth-of-type(-n + 3) {
	margin-right: 5px;
}
.action-group p {
	background-color: rgb(150,150,150);
	padding: 10px 15px;
	text-align: center;
}
.active-tab {
	background-color: rgb(110,110,110) !important;
}
.action-content {
	padding: 10px;
	grid-column: 1 / span 4 !important;
}
.tab {
	cursor: pointer;
}
.action-content-hide {
	display: none;
}

@media only screen and (max-width: 992px) {
	.tabs-accordion {
		display: block;
	}
	.action-group {
		margin-bottom: 20px;
	}
	.action-group {
		grid-template-areas:
			"tabOne" "contentOne"
			"tabTwo" "contentTwo"
			"tabThree" "contentThree"
			"tabFour" "contentFour";
	}
	.action-group > div {
		grid-column: 1 / span 4 !important;
	}
	.action-group > div:nth-of-type(-n + 3) {
		margin-right: 0;
	}
}

              
            
!

JS

              
                var actionContent = document.querySelectorAll(".action-content"),
	actionTab = document.getElementsByClassName("tab"),
	actionContentArr = Array.from(actionContent),
	actionTabArr = Array.from(actionTab);

// Hide sections
function hideSections() {
	for (var i = 0; i < actionContentArr.length; i++) {
		actionContentArr[i].classList.add("action-content-hide");
	}
}

// Tab click events
for (var i = 0; i < actionTabArr.length; i++) {
	actionTabArr[i].addEventListener("click", function (e) {
		hideSections();
		actionContentArr[this.dataset.tab].classList.remove("action-content-hide");
	});
}

window.onresize = function () {
	if (window.innerWidth < 993) {
		for (var i = 0; i < actionContentArr.length; i++) {
			actionContentArr[i].classList.add("action-content-hide");
		}
	} else {
		hideSections();
	}
	actionContentArr[0].classList.remove("action-content-hide");
};

              
            
!
999px

Console