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

              
                <table id="bigdata">
</table>
              
            
!

CSS

              
                /*
hover a cell, fill it in red
*/
#bigdata tr > *:hover {
	background: red;
}

/* 
highlight the cells in the row before the hovered cell
*/
#bigdata tr > *:has(~ *:hover) {
	background: rgba(255,0,0,0.33);
}

/*
and now the down-the-column highlighting; it’s hacky but I couldn’t think of another way to make it work with :has()
maybe https://github.com/w3c/csswg-drafts/issues/4559 would allow for a one-selector rule? not sure
*/

#bigdata tr:has(~ tr:hover > *:nth-child( 1):hover) > *:nth-child( 1),
#bigdata tr:has(~ tr:hover > *:nth-child( 2):hover) > *:nth-child( 2),
#bigdata tr:has(~ tr:hover > *:nth-child( 3):hover) > *:nth-child( 3),
#bigdata tr:has(~ tr:hover > *:nth-child( 4):hover) > *:nth-child( 4),
#bigdata tr:has(~ tr:hover > *:nth-child( 5):hover) > *:nth-child( 5),
#bigdata tr:has(~ tr:hover > *:nth-child( 6):hover) > *:nth-child( 6),
#bigdata tr:has(~ tr:hover > *:nth-child( 7):hover) > *:nth-child( 7),
#bigdata tr:has(~ tr:hover > *:nth-child( 8):hover) > *:nth-child( 8),
#bigdata tr:has(~ tr:hover > *:nth-child( 9):hover) > *:nth-child( 9),
#bigdata tr:has(~ tr:hover > *:nth-child(10):hover) > *:nth-child(10),
#bigdata tr:has(~ tr:hover > *:nth-child(11):hover) > *:nth-child(11),
#bigdata tr:has(~ tr:hover > *:nth-child(12):hover) > *:nth-child(12),
#bigdata tr:has(~ tr:hover > *:nth-child(13):hover) > *:nth-child(13),
#bigdata tr:has(~ tr:hover > *:nth-child(14):hover) > *:nth-child(14),
#bigdata tr:has(~ tr:hover > *:nth-child(15):hover) > *:nth-child(15),
#bigdata tr:has(~ tr:hover > *:nth-child(16):hover) > *:nth-child(16),
#bigdata tr:has(~ tr:hover > *:nth-child(17):hover) > *:nth-child(17),
#bigdata tr:has(~ tr:hover > *:nth-child(18):hover) > *:nth-child(18),
#bigdata tr:has(~ tr:hover > *:nth-child(19):hover) > *:nth-child(19),
#bigdata tr:has(~ tr:hover > *:nth-child(20):hover) > *:nth-child(20),
#bigdata tr:has(~ tr:hover > *:nth-child(21):hover) > *:nth-child(21),
#bigdata tr:has(~ tr:hover > *:nth-child(22):hover) > *:nth-child(22),
#bigdata tr:has(~ tr:hover > *:nth-child(23):hover) > *:nth-child(23),
#bigdata tr:has(~ tr:hover > *:nth-child(24):hover) > *:nth-child(24),
#bigdata tr:has(~ tr:hover > *:nth-child(25):hover) > *:nth-child(25) {
	background: rgba(255,0,0,0.33);
}


/*
I thought this might somehow magically work despite the structural situation, but no dice
*/
#bigdata col td:has(td:hover) {
	font-style: italic;
}


/*
the following is other styling of the table and cells
*/

#bigdata {
	border-spacing: 0;
}
#bigdata tr:nth-child(odd) {
	background: #EEE;
}
#bigdata tr > * {
	padding-block: 0.33em;
	padding-inline: 0.5em;
	transition-duration: 150ms;
}

              
            
!

JS

              
                let table = document.getElementById('bigdata');
let rows = 25;
let cols = 25;

let colgroup = document.createElement('colgroup');
for (i = 0; i < rows; i++) {
	let newcol = document.createElement('col');
	colgroup.appendChild(newcol);
}
table.appendChild(colgroup);

for (i = 0; i < rows; i++) {
	let newRow = document.createElement('tr');
	for (j = 0; j < cols; j++) {
		let newCell = document.createElement('td');
		newCell.textContent = Math.round(Math.random() * 10000);
		newRow.appendChild(newCell);
	}
	table.appendChild(newRow);
}
              
            
!
999px

Console