cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

              <!-- div.button.button--${button$}*4 -->
<div class="left">
	<div class="button button--1" data-article="article1">button1</div>
	<div class="button button--2" data-article="article2">button2</div>
	<div class="button button--3" data-article="article3">button3</div>
	<div class="button button--4" data-article="article4">button4</div>
<div class="right">
	<div class="article article--active article1" data-article="article1" data-color="#9EFF00">article1</div>
	<div class="article article2" data-article="article2" data-color="#FF1F00">article2</div>
	<div class="article article3" data-article="article3" data-color="#001BFF">article3</div>
	<div class="article article4" data-article="article4" data-color="#FF00E8">article4</div>

	width: 100px
	line-height: 30px
	border: 1px solid black
	border-radius: 10px
	text-align: center

		background-color: #9EFF00
		background-color: #FF1F00
		background-color: #001BFF
		background-color: #FF00E8

	float: left

	float: left
	width: 200px
	height: 150px
	padding: 20px
	background-color: yellow
	text-align: center

	display: none

		display: block
              class Search {
	constructor() {

	init() {

	setConst() {
		this.$window = $(window);
		this.$clickTarget = $(".button");
		this.allArticle = $(".article");
		this.slideTarget = $(".right");
		this.searchData = "article";
		this.activeClass = "article--active"
		//State 現在開いている記事がどれか
		this.oepnedTargetData = "article1";
		this.targetData = null;
		this.$animationTarget = null;
		this.duration = 500;
	attachClickEvent() {
		this.$clickTarget.on("click.test", (event) => {
			const $target = $(event.currentTarget);
			this.targetData = $target.data(this.searchData);
			this.allArticle.each((index, element) => {
				const $element = $(element);

				if (!($element.data(this.searchData) === this.targetData)) {
					//jQueryのメソッド「.each」の中でreturn true をすると、
					return true;

				if (this.targetData === this.oepnedTargetData) {
					//jQueryのメソッド「.each」の中でreturn false をすると、
					//全ての要素への実行を飛ばす。つまり each全体の実行がこの段階で終わる
					return false;

				this.$animationTarget = $element;
				this.color = $element.data("color");

	listenEvent() {
		this.$window.on("trigger.test", () => {
			this.slideTarget.velocity("slideUp", {
				duration: this.duration,
				complete: () => {
					this.slideTarget.css("background-color", this.color)
					.velocity("slideDown", {
						duration: this.duration,
						complete: () => {
							this.oepnedTargetData = this.targetData;

new Search();


Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................