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">
	<header>
		<h1> Kids’ timetable generator</h1>
	</header>
	<div class="button-wrapper">
		<button data-btn type="button">Sort activities</button>
		<button class="clear-button" data-clear type="button">Clear timetable</button>
	</div>
	<div class="grid">
		<table>
			<thead>
				<th scope="col">Time</th>
				<th scope="col">Monday</th>
				<th scope="col">Tuesday</th>
				<th scope="col">Wednesday</th>
				<th scope="col">Thursday</th>
				<th scope="col">Friday</th>
			</thead>
			<tbody>
				<tr>
					<th scope="row">7:30am</th>
					<td><span>Breakfast</span></td>
					<td><span>Breakfast</span></td>
					<td><span>Breakfast</span></td>
					<td><span>Breakfast</span></td>
					<td><span>Breakfast</span></td>
				</tr>
				<tr class="bg-yellow">
					<th scope="row">9:00am</th>
					<td><span>Exercise</span></td>
					<td><span>Exercise</span></td>
					<td><span>Exercise</span></td>
					<td><span>Exercise</span></td>
					<td><span>Exercise</span></td>
				</tr>
				<tr class="bg-green">
					<th scope="row">9:30am</th>
					<td><span>Free play</span></td>
					<td><span>Free play</span></td>
					<td><span>Free play</span></td>
					<td><span>Free play</span></td>
					<td><span>Free play</span></td>
				</tr>
				<tr>
					<th scope="row">10:00am</th>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
				</tr>
				<tr>
					<th scope="row">11:00am</th>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
				</tr>
				<tr>
					<th scope="row">12:00</th>
					<td><span>Lunch</span></td>
					<td><span>Lunch</span></td>
					<td><span>Lunch</span></td>
					<td><span>Lunch</span></td>
					<td><span>Lunch</span></td>
				</tr>
				<tr class="bg-green">
					<th scope="row">1:00pm</th>
					<td><span>Free play</span></td>
					<td><span>Free play</span></td>
					<td><span>Free play</span></td>
					<td><span>Free play</span></td>
					<td><span>Free play</span></td>
				</tr>
				<tr>
					<th scope="row">2:00pm</th>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
				</tr>
				<tr>
					<th scope="row">3:00pm</th>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
				</tr>
				<tr>
					<th scope="row">4:00pm</th>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
					<td data-cell></td>
				</tr>
				<tr class="bg-green">
					<th scope="row">5:00pm</th>
					<td><span>Free play/TV</span></td>
					<td><span>Free play/TV</span></td>
					<td><span>Free play/TV</span></td>
					<td><span>Free play/TV</span></td>
					<td><span>Free play/TV</span></td>
				</tr>
				<tr>
					<th scope="row">6:00pm</th>
					<td><span>Dinner</span></td>
					<td><span>Dinner</span></td>
					<td><span>Dinner</span></td>
					<td><span>Dinner</span></td>
					<td><span>Dinner</span></td>
				</tr>
			</tbody>
		</table>

		<ul class="activities" data-activities>
			<li>
				<div class="activity" style="--bg: #adff8a; --r: -2deg">Baking</div>
			</li>
			<li>
				<div class="activity" style="--r: -4deg">Painting</div>
			</li>
			<li>
				<div class="activity" style="--bg: #ff8af5; --r: 2.5deg">Painting</div>
			</li>
			<li>
				<div class="activity" style="--bg: #adff8a; --r: 1.25deg">Treasure hunt</div>
			</li>
			<li>
				<div class="activity" style="--bg: #ff8af5; --r: -2deg">Cutting and sticking</div>
			</li>
			<li>
				<div class="activity" style="--bg: #adff8a; --r: 2.5deg">Cutting and sticking</div>
			</li>
			<li>
				<div class="activity" style="--r: -4deg">Drawing/writing practice</div>
			</li>
			<li>
				<div class="activity" style="--bg: #ff8af5; --r: 1.25deg">Drawing/writing practice</div>
			</li>
			<li>
				<div class="activity" style="--bg: #adff8a; --r: -2deg">Indoor games</div>
			</li>
			<li>
				<div class="activity" style="--bg: #ff8af5; --r: 2.5deg">Board games/puzzles</div>
			</li>
			<li>
				<div class="activity" style="--bg: #adff8a; --r: -4deg">Nature walk</div>
			</li>
			<li>
				<div class="activity" style="--r: 1.25deg">Outdoor games</div>
			</li>
			<li>
				<div class="activity" style="--r: -4deg">Building blocks/Lego</div>
			</li>
			<li>
				<div class="activity" style="--bg: #adff8a; --r: 2.5deg">Play-doh</div>
			</li>
			<li>
				<div class="activity" style="--r: -2deg">Stickers</div>
			</li>
			<li>
				<div class="activity" style="--bg: #ff8af5; --r: 1.25deg">Making/crafting</div>
			</li>
			<li>
				<div class="activity" style="--bg: #adff8a; --r: -4deg">Shopping</div>
			</li>
			<li>
				<div class="activity" style="--bg: #ff8af5; --r: -2deg">Monster truck race course</div>
			</li>
			<li>
				<div class="activity" style="--bg: #adff8a; --r: -4deg">Running</div>
			</li>
			<li>
				<div class="activity" style="--r: 1.25deg">Running</div>
			</li>
			<li>
				<div class="activity" style="--r: -2deg">Reading</div>
			</li>
			<li>
				<div class="activity" style="--bg: #ff8af5; --r: -4deg">Family Facetime</div>
			</li>
			<li>
				<div class="activity" style="--r: 2.5deg">Gardening</div>
			</li>
			<li>
				<div class="activity" style="--bg: #adff8a; --r: 1.25deg">Cars</div>
			</li>
			<li>
				<div class="activity" style="--bg: #ff8af5;   --r: 2.5deg">Chalks</div>
			</li>
		</ul>
	</div>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Caveat+Brush|Ubuntu:400,700&display=swap');

$pink: #ff8af5;
$yellow: #fcf3b8;
$green: #adff8a;

* {
	box-sizing: border-box;
}

body {
	font-family: 'Ubuntu', sans-serif;
}

button {
	background-color: #da42f5;
	border: none;
	padding: 1rem 2rem;
	color: white;
	font-size: 1.2rem;
	font-family: inherit;
	border-radius: 0.4rem;
	margin-right: 1rem;
	
	&:hover,
	&:focus {
		background-color: darken(#da42f5, 20%);
	}
	
	&.clear-button {
		background-color: #67f5dd;
		color: black;
		
		&:hover,
	&:focus {
		background-color: darken(#67f5dd, 20%);
	}
	}
}

.button-wrapper {
	display: flex;
	flex-wrap: wrap;
}

table {
	text-align: left;
	border-collapse: collapse;
}

th,
td {
	vertical-align: top;
	padding: 0.75rem;
}

td {
	font-family: 'Caveat Brush', cursive;
	font-size: 1.2rem;
	border: 3px solid;
	min-width: 10rem;
	
	span {
		background-color: $pink;
	}
	
	&[data-cell] {
		height: 10rem;
	}
}

.bg-yellow {
	td {
		span {
			background-color: $yellow;
		}
	}
}

.bg-green {
	td {
		span {
			background-color: $green;
		}
	}
}

thead {
	th {
		border-right: 3px solid;
	}
}

tbody {
	th {
		border-top: 3px solid;
	}
	
	tr:last-child {
		th {
			border-bottom: 3px solid;
		}
	}
}

.wrapper {
	max-width: 90rem;
	padding: 1rem 2rem;
	margin: 0 auto;
}

.activity {
	width: 8rem;
	min-height: 8rem;
	display: block;
	hyphens: auto;
	padding: 0.5rem;
	background-color: var(--bg, $yellow);
	text-align: center;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0.2rem 0.2rem 0.75rem rgba(0, 0, 0, 0.2);
	font-family: 'Caveat Brush', cursive;
	font-size: 1.2rem;
	transform: rotate(var(--r, -2deg));
}

.activities {
	list-style: none;
	margin: 0;
	padding: 0;
	flex: 1 1 auto;
	display: grid;
	grid-template-columns: repeat(3, 8rem);
	gap: 1rem;
	
	li {
		min-height: 8rem;
		display: block;
		hyphens: auto;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
		font-family: 'Caveat Brush', cursive;
		font-size: 1.2rem;
	}
	
	@media (min-width: 85rem) {
		max-width: 40rem;
		margin-left: auto;
	}
}

.grid {
	margin-top: 2rem;
	
	@media (min-width: 85rem) {
		display: grid;
		grid-template-columns: 40rem 1fr;
		gap: 2rem;
		align-items: start;
	}
}
              
            
!

JS

              
                const listEl = document.querySelector('[data-activities]')
const activities = [...document.querySelectorAll('[data-activities] li')]
const cells = [...document.querySelectorAll('[data-cell]')]
const btn = document.querySelector('[data-btn]')
const clear = document.querySelector('[data-clear]')

const shuffle = (array) => {
	let a = [...array]
	
	for (let i = a.length - 1; i > 0; i--) {
		const j = Math.floor(Math.random() * (i + 1));
		[a[i], a[j]] = [a[j], a[i]];
	}
	
	return a
}

const clearTimetable = () => {
	cells.forEach((el, i) => {
		el.innerHTML = ''
	})
	
	listEl.style.display = 'grid'
}

const sortActivities = () => {
	const activitiesList = shuffle(activities)
	
	cells.forEach((el, i) => {
		el.innerHTML = ''
		
		if (i < activities.length) {
			el.innerHTML = `${activitiesList[i].innerHTML}`
		}
	})
	
	listEl.style.display = 'none'
}

btn.addEventListener('click', sortActivities)
clear.addEventListener('click', clearTimetable)
              
            
!
999px

Console