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

              
                <header>
	<h1>February 2022</h1>
	<p>Holidays and Daily Observances in the United States</p>
</header>
<div class="container">
	<ul></ul>
	<div class="controls">
		<button onclick="adjustDay(-1)">▲</button>
		<button onclick="adjustDay(1)">▼</button>
	</div>
</div>
              
            
!

CSS

              
                * {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	min-height: 100vh;
	display: grid;
	place-items: center;
	overflow: hidden;
	font-family: sans-serif;
	background-color: rgb(6, 6, 6);
	background-image: linear-gradient(rgb(0, 0, 0, 0.5), rgb(0, 0, 0, 0.5));
	color: white;
	transition: background-color 500ms ease;
}

/* header */
header {
	position: absolute;
	z-index: 999;
	text-align: center;
	top: 0rem;
	padding: 1rem;
	background: inherit;
}

.container {
	position: relative;
	width: min(400px, 100%);
}

/* holidays */
ul {
	list-style: none;
	width: 100%;
	height: 100%;
	position: relative;
	perspective: 900px;
	transform-style: preserve-3d;
}
ul > li {
	position: absolute;
	left: 50%;
	top: calc(50% - 1.2rem);
	--rotateX: calc(
		1deg * var(--rotateDegrees) * calc(var(--day_idx) - var(--currentDay))
	);
	transform: rotateX(var(--rotateX)) translateZ(190px) translateX(-50%)
		scale(var(--scale, 1));
	--hue: calc(var(--rotateDegrees) * var(--day_idx));
	background-color: hsl(var(--hue), 50%, var(--lightness, 50%));
	width: 70%;
	color: white;
	display: grid;
	grid-template-columns: 2.5rem auto;
	height: 2.4rem;
	transition: transform 500ms ease, background-color 500ms ease;
}

ul > li.active {
	--lightness: 30%;
	--scale: 1.1;
}
ul > li > * {
	display: grid;
	align-items: center;
}
li > time {
	text-align: center;
}
li > span {
	padding-inline-start: 0.5rem;
	color: white;
}

/* controls */
.controls {
	position: absolute;
	top: 50%;
	left: 100%;
	transform: translateY(-50%);
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
}
.controls button {
	width: 1.5rem;
	aspect-ratio: 1;
	font-size: 0.9rem;
	color: white;
	border: none;
	background: #39657e;
	display: grid;
	place-items: center;
}
.controls button:hover,
.controls button:focus {
	background: rgb(6, 60, 131);
}
.controls button:active {
	transform: scale(0.9);
}
.border {
	width: 96%;
	height: 3em;
	border: 1px solid white;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}

              
            
!

JS

              
                const febHolidays = [
	"Dark Chocolate Day",
	"Groundhog Day",
	"Carrot Cake Day",
	"Wear Red Day",
	"Weatherperson's Day",
	"Chopsticks Day",
	"Periodic Table Day",
	"Kite Flying Day",
	"Pizza Day",
	"Umbrella Day",
	"Inventor's Day",
	"Global Movie Day",
	"Tortellini Day",
	"Valentine's Day",
	"Gumdrop Day",
	"Do a Grouch a Favor Day",
	"Cabbage Day",
	"Battery Day",
	"Chocolate Mint Day",
	"Love Your Pet Day",
	"President's Day",
	"Cook a Sweet Potato Day",
	"Tile Day",
	"Toast Day",
	"Clam Chowder Day",
	"Pistachio Day",
	"Polar Bear Day",
	"Tooth Fairy Day"
];

const ulEl = document.querySelector("ul");
const d = new Date();
let daynumber = d.getMonth() == 1 ? d.getDate() - 1 : 0;
let activeIndex = daynumber;
const rotate = -360 / febHolidays.length;
init();

function init() {
	febHolidays.forEach((holiday, idx) => {
		const liEl = document.createElement("li");
		liEl.style.setProperty("--day_idx", idx);
		liEl.innerHTML = `<time datetime="2022-02-${idx + 1}">${
			idx + 1
		}</time><span>${holiday}</span>`;
		ulEl.append(liEl);
	});
	ulEl.style.setProperty("--rotateDegrees", rotate);
	adjustDay(0);
}

function adjustDay(nr) {
	daynumber += nr;
	ulEl.style.setProperty("--currentDay", daynumber);

	const activeEl = document.querySelector("li.active");
	if (activeEl) activeEl.classList.remove("active");

	activeIndex = (activeIndex + nr + febHolidays.length) % febHolidays.length;
	const newActiveEl = document.querySelector(`li:nth-child(${activeIndex + 1})`);
	document.body.style.backgroundColor = window.getComputedStyle(
		newActiveEl
	).backgroundColor;

	newActiveEl.classList.add("active");
}

window.addEventListener("keydown", (e) => {
	switch (e.key) {
		case "ArrowUp":
			adjustDay(-1);
			break;
		case "ArrowDown":
			adjustDay(1);
			break;
		default:
			return;
	}
});

              
            
!
999px

Console