cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <!-- Increase $anim-duration variable if you want to see slower :) (I set it as 5s so it can complete in the thumbnail) -->

<div class="description">
	<h1>Daily CSS Images: Day 7</h2>
	<h2>Christian Valentin</h2>
	<h3>How to draw a square</h3>
</div>

<div class="ruler">
	<div class="metric"></div>
	<div class="metric"></div>
	<div class="metric"></div>
	<div class="metric"></div>
	<div class="metric"></div>
	<div class="metric"></div>
	<div class="metric"></div>
</div>
<div class="pencil">
	<div class="tip"></div>
	<div class="body"></div>
</div>
<div class="square">
	<div class="left"></div>
	<div class="top"></div>
	<div class="right"></div>
	<div class="bottom"></div>
</div>
            
          
!
            
              $bg: #9b59b6;
body {
	background: $bg;
}

// Increase $anim-duration variable if you want to see slower :) (I set it as 5s so it can complete in the thumbnail
$anim-duration: 5s;
.description {
	@include anim-delay($anim-duration);
}

.ruler {
	@include animation(ruler-movement, $anim-duration);
	@include trsf(translateY(-10px) translateX(-100px) rotate(180deg));
	position: absolute;
	z-index: 1;
	$main-color: #ffd185;
	$black: #362c34;
	@include bdrds(10px);
	width: 100px;
	padding: 20px 0;
	background: $main-color;
	&:before {
		@include bdrds();
		content: "";
		display: block;
		width: 15px;
		height: 15px;
		background: $black;
		margin: auto;
	}
	.metric {
		display: block;
		border-top: 7px solid $black;
		width: 40px;
		margin-top: 10px;
		@include pseudo() {
			display: block;
			position: static;
			border-top: 7px solid $black;
			width: 20px;
			margin-top: 10px;
		}
		;
	}
}

.pencil {
	@include trsf(translateY(400px) translateX(-15px) rotate(230deg), 50% 0);
	@include animation(pencil-movement, $anim-duration);
	position: absolute;
	z-index: 1;
	$black: #000000;
	$tip: #ffd185;
	$yellow: #fefc3b;
	$width: 30px;
	$height: 300px;
	$tip-height: ($height * (80 / 580));
	$body-height: ($height - $tip-height);
	.tip {
		width: 0;
		height: 0;
		border-left: ($width / 2) solid transparent;
		border-right: ($width / 2) solid transparent;
		border-bottom: $tip-height solid $tip;
		&:before {
			content: "";
			position: absolute;
			top: 0;
			left: -($width / 4);
			width: 0;
			height: 0;
			border-left: ($width / 4) solid transparent;
			border-right: ($width / 4) solid transparent;
			border-bottom: ($tip-height / 2) solid black;
		}
	}
	.body {
		width: $width;
		height: $body-height;
		border-left: ($width / 2) solid $yellow;
		border-right: ($width / 2) solid $black;
	}
}

.square {
	$size: 400px;
	width: $size;
	height: $size;
	div {
		box-sizing: initial;
		position: absolute;
	}
	.left {
		@include trsf(scaleY(0), 0 100%);
		@include animation(draw-vertical, ($anim-duration * (1.25 / 10)));
		top: 0;
		left: 0;
		height: $size;
		border-right: 5px solid black;
	}
	.top {
		@include trsf(scaleX(0), 0 0);
		@include animation(draw-horizontal, ($anim-duration * (1.25 / 10)), ease, (($anim-duration * (1.25 / 10) * 2) + 1s));
		top: 0;
		left: 0;
		width: $size;
		border-bottom: 5px solid black;
	}
	.right {
		@include trsf(scaleY(0), 0 0);
		@include animation(draw-vertical, ($anim-duration * (1.25 / 10)), ease, (($anim-duration * (1.25 / 10) * 4) + 1s));
		top: 0;
		right: 0;
		height: $size;
		border-left: 5px solid black;
	}
	.bottom {
		@include trsf(scaleX(0), 100% 0);
		@include animation(draw-horizontal, ($anim-duration * (1.25 / 10)), ease, (($anim-duration * (1.25 / 10) * 6) + 1s));
		bottom: 0;
		right: 0;
		width: $size;
		border-top: 5px solid black;
	}
}

@include keyframe(ruler-movement) {
	0% {
		@include trsf(translateY(-10px) translateX(-100px) rotate(180deg));
	}
	12.5% {
		@include trsf(translateY(-10px) translateX(-100px) rotate(180deg));
	}
	25% {
		@include trsf(translateY(-255px) translateX(150px) rotate(270deg));
	}
	37.5% {
		@include trsf(translateY(-255px) translateX(150px) rotate(270deg));
	}
	50% {
		@include trsf(translateY(-10px) translateX(400px) rotate(360deg));
	}
	62.5% {
		@include trsf(translateY(-10px) translateX(400px) rotate(360deg));
	}
	75% {
		@include trsf(translateY(245px) translateX(150px) rotate(450deg));
	}
	82.5% {
		@include trsf(translateY(245px) translateX(150px) rotate(450deg));
	}
	100% {
		@include trsf(translateY(40px) translateX(50px) rotate(510deg));
	}
}

@include keyframe(pencil-movement) {
	0% {
		@include trsf(translateY(400px) translateX(-15px) rotate(-120deg));
	}
	12.5% {
		@include trsf(translateY(0px) translateX(-15px) rotate(-50deg));
	}
	25% {
		@include trsf(translateY(0px) translateX(-15px) rotate(-50deg));
	}
	37.5% {
		@include trsf(translateY(0px) translateX(385px) rotate(40deg));
	}
	50% {
		@include trsf(translateY(0px) translateX(385px) rotate(40deg));
	}
	62.5% {
		@include trsf(translateY(400px) translateX(385px) rotate(120deg));
	}
	75% {
		@include trsf(translateY(400px) translateX(385px) rotate(120deg));
	}
	87.5% {
		@include trsf(translateY(400px) translateX(-15px) rotate(230deg));
	}
	100% {
		@include trsf(translateY(130px) translateX(165px) rotate(400deg));
	}
}

@include keyframe(draw-vertical) {
	0% {
		@include trsf(scaleY(0));
	}
	100% {
		@include trsf(scaleY(1));
	}
}

@include keyframe(draw-horizontal) {
	0% {
		@include trsf(scaleX(0));
	}
	100% {
		@include trsf(scaleX(1));
	}
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console