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

              
                html
p navigate using arrow keys
.ocean
	#fish
	#boat
		#hook




              
            
!

CSS

              
                
//define colors
$blue: blue
$red: #ff5500
$darkblue: #320efc
//text styles
p
	text-align: center
	font-family: Inconsolata
	color: #101010
	font-size: 14px
	font-weight: 400

//define animation
@keyframes drop
	0%
		margin-top: 100px
	100%
		margin-top: 200px

//define animation
@keyframes drop
	0%
		margin-top: 100px
	100%
		margin-top: 200px


.ocean
	position: fixed
	bottom: 0
	height: 40%
	width: 100%
	background: black
	z-index: -1
	animation: wave 1.4s ease-in-out infinite alternate
	//boat
	#boat
		background: blue
		height: 25px
		width: 50px
		border-radius: 0 0 10px 10px
		position: absolute
		// margin-top: -2%
		z-index: 4
		
	#hook
		background: $red
		height: 50px
		width: 5px
		position: absolute
		top: -5px
		left: 5px
		z-index: 2
		&:after
			content: ""
			background: $red
			width: 15px
			height: 5px
			position: absolute
			bottom: 0
			z-index: 5

	//fish
	#fish
		content: ""
		background: white
		height: 20px
		width: 20px
		position: absolute
		margin-top: 4%
		z-index: 0
		animation: bubble 4s ease-in-out infinite 
		//animation: bubble 4s ease-in-out infinite 
//define animation
@keyframes wave
	0%
		height: 43%
	100%
		height: 40%
//define animation
@keyframes bubble
	0%
		margin-top: 6% 
		left: 100px
		border-radius: 0 10px 10px 0
	30%
		margin-top: 3%  
		left: 400px
		border-radius: 0 10px 10px 0
	56%
		margin-top: 10%
		left: 600px
		border-radius: 10px 0 0 10px
	60%
		margin-top: 10%
		left: 600px
		border-radius: 10px 0 0 10px
	96%
		margin-top: 6% 
		left: 100px
		border-radius: 0 10px 10px 0
	100%
		margin-top: 6% 
		left: 100px
		border-radius: 0 10px 10px 0
@keyframes boatColor
	0%
		background: $blue
		margin-top: -2%
	100%
		background: $darkblue
		margin-top: -1%

              
            
!

JS

              
                //define object boat, with move left and move right
function boatMove(initialPos){
var boat = document.getElementById("boat");
var hook = document.getElementById("hook");
	countX = 1;
	countY = 1;
	//set initial position & hook height
	boat.style.transform="translateX"+"("+initialPos+"px)";
	hook.style.height="5px";
	//set default self-contained animation
	boat.style.animation="boatColor 1s ease-in-out infinite alternate";
	//key controled animation
	window.addEventListener("keydown",function(event){
		//return keycode value
		var keyvalue = event.which || event.keycode;
		//pass in initial position
		x=initialPos;
		if (keyvalue==39){
			boat.style.transform="translateX"+"("+(x+20*countX)+"px)";
		countX +=1;
		}
		if (keyvalue==37){
			boat.style.transform="translateX"+"("+(x+20*countX)+"px)";
		countX -=1;
		}
		if (keyvalue==40){
			hook.style.height=(25+5*countY)+"px";
		countY +=1;
		}
		if (keyvalue==38){
			hook.style.height=(25+5*countY)+"px";
		countY -=1;
		}
	});

}

boatMove(100); 
              
            
!
999px

Console