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.

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

            
              <div id="app"></div>
            
          
!

CSS

            
              #clock
	font-family Roboto
	height 100vh
	width 100vw
	display flex
	align-items center
	justify-content center
	color #fff
	background-color #111
	transition .5s
	h1
		font-size 7em
		cursor pointer
		transition .2s
		&::selection
			background-color transparent
			
			
.faded
	opacity 0
	
#instruction
	position absolute
	width 100vw
	text-align center
	color #fff
	font-family Roboto
	font-size 18px
            
          
!

JS

            
              class Clock extends React.Component{
	constructor() {
		super()
		this.state = {
			time: moment().format('LTS'),
			one: true,
			two: false,
			three: false,
			four: false,
			background: {
				backgroundColor: "#000000".replace(/0/g,function(){return (~~(Math.random()*16)).toString(16)})
			},
			class: ''
		}
		this.clicked = this.clicked.bind(this)
	}
	componentDidMount() {
		setInterval(()=>{
			if(this.state.one == true) {
				this.setState({
					time: moment().format('LTS')
				})
			}
			else if(this.state.four == true){
				this.setState({
					time: moment().format('LT')
				})
			}
		},1000)
	}
	clicked() {
		this.setState({
			background: {
				backgroundColor: "#000000".replace(/0/g,function(){return (~~(Math.random()*16)).toString(16)})
			}
		})
		if(this.state.one == true) {
			this.setState({class: 'faded'})
			setTimeout(()=>{
				this.setState({
					time: moment().format('l'),
					one: false,
					two: true,
					class: ''
				})
			},200)
		}
		else if(this.state.two == true) {
			this.setState({class: 'faded'})
			setTimeout(()=>{
				this.setState({
					time: moment().format('MMMM Do YY'),
					two: false,
					three: true,
					class: ''
				})
			},200)
		}
		else if(this.state.three == true) {
			this.setState({class: 'faded'})
			setTimeout(()=>{
				this.setState({
					time: moment().format('LT'),
					three: false,
					four: true,
					class: ''
				})
			},200)
		}
		else if(this.state.four == true) {
			this.setState({class: 'faded'})
			setTimeout(()=>{
				this.setState({
					time: moment().format('LTS'),
					four: false,
					one: true,
					class: ''
				})
			},200)
		}
	}
	render() {
		return(
			<div id="clock" style={this.state.background} onClick={this.clicked}>
				<h1 className={this.state.class}>{this.state.time}</h1>
			</div>
		)
	}
}

class Instruction extends React.Component {
	render() {
		return(
			<p id="instruction">Click anywhere to change formats</p>
		)
	}
}

class App extends React.Component {
	render() {
		return(
			<div>
				<Instruction/>
				<Clock/>
			</div>
		)
	}
}

ReactDOM.render(<App/>,document.getElementById('app'))
            
          
!
999px

Console