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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                -# Using some Haml for less typing :)

%div.automaton
	- (1..91).each do
		%input{type: "checkbox"}
		
%button.js-unchecker.u-margin-top
	Uncheck all
              
            
!

CSS

              
                //
// Welcome to the CSS encoding of the Cellular Automaton Rule 190!
// Learn about Cellular Automata here: 
// https://notlaura.com/is-css-turing-complete/
// 

// Store custom property definitions in mixins for easier updating. 
// (we'll be able to do this in CSS soon enough!)
@mixin zero {
	--cell-bg-color: white;
	--cell-num-color: black;
	--cell-content: "0";
}

@mixin one {
	--cell-bg-color: hotpink;
	--cell-num-color: white;
	--cell-content: "X";
	--cell-cursor: pointer;
}

// Number of *s should be: var( --cells-per-row ) - 1. 
// This means go to one cell before the one right below the current target.
$selector: "* + * + * + * + * + * + * + * + * + * + * + *";

//
// Rule 190 Encoding:
// 111 110 101 100 011 010 001 000
//  1   0   1   1   1   1   1   0
//

// 111
input:checked + input:checked + input:checked 
+ #{$selector} {
	@include one;
}

// 110
input:checked + input:checked + input:not(:checked) 
+ #{$selector} {
	@include zero;
}

// 101
input:checked + input:not(:checked) + input:checked 
+ #{$selector} {
	@include one;
}

// 100
input:checked + input:not(:checked) + input:not(:checked) 
+ #{$selector} {
	@include one;
}

// 011
input:not(:checked) + input:checked + input:checked 
+ #{$selector} {
	@include one;
}

// 010
input:not(:checked) + input:checked + input:not(:checked) 
+ #{$selector} {
	@include one;
}

// 001
input:not(:checked) + input:not(:checked) + input:checked 
+ #{$selector} {
	@include one;
}

// 000
input:not(:checked) + input:not(:checked) + input:not(:checked)
+ #{$selector} {
	@include zero;
}





//
// UI setup - not relevant to the CA logic.
//

// Set up the custom properties
:root {
	--cell-content: "";
	--cell-bg-color: white;
	--cell-num-color: black;
	--cell-cursor: initial;
	
	--cell-size: 40px;
	--cells-per-row: 13;
}

// Configuration previous row checked items.
input:checked::before {
	--cell-bg-color: black;
	--cell-cursor: initial;
	--cell-num-color: white;
	--cell-content: "1";
}

input:not(:checked) {
	@include zero;
}

// Scaffold number indicator pattern
input::before {
	width: 100%;
	height: 100%;
	position: absolute;
	display: grid;
	place-content: center;
	background-color: var( --cell-bg-color );
	color: var( --cell-num-color );
	content: var( --cell-content );
	cursor: var( --cell-cursor );
}

.automaton {
	display: flex;
	flex-wrap: wrap;
	width: calc( var( --cell-size) * var( --cells-per-row ) );
}

input {
	-webkit-appearance: none;	
	border: 1px solid black;
	height: var( --cell-size );
	width: var( --cell-size );
	font-size: 1rem;
	margin: 0;
	position: relative;
}


// Indicate starting cell with an X

input:nth-child(7) {
	border: 4px solid hotpink;
}

input:nth-child(7):checked {
	border: unset;
}

input:nth-child(7)::before {
	content: "X";
	cursor: pointer;
}

input:nth-child(7):checked::before {
	content: "1";
}


// Utilities

.u-margin-top {
	margin-top: 2rem;
}



              
            
!

JS

              
                const cells = document.querySelectorAll( 'input[type="checkbox"]' );
const uncheckerBtn = document.querySelector( '.js-unchecker' );

uncheckerBtn.addEventListener( 'click', function( e ) {
	cells.forEach( ( cell ) => {
		cell.checked = false;
	});
});
              
            
!
999px

Console