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 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

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

              
                <!DOCTYPE html>
<!-- Space Crawl adapted for CSS Tricks Tutorial -->
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title>Star Wars API</title>
	<link rel="stylesheet" type="text/css" href="stylesheet.css">
	<link href="https://fonts.googleapis.com/css?family=Montserrat|Montserrat+Subrayada&display=swap" rel="stylesheet">
</head>
	
<body>
<!-- partial:index.partial.html -->
<audio id="swmusic" loop >
	<source src="https://s.cdpn.io/1202/Star_Wars_original_opening_crawl_1977.mp3#t=00:00:08">
</audio>
	
<div id="wrapper">
	
<img id="logo" src="http://imageshack.com/a/img922/3783/oyvsRd.png">

	<h1 id="toptext">CHARACTER STATS</h1>
	
	<button id="controlbtn">PLAY MUSIC</button>
	<br>

	<label for="query">Search for a Character: </label>

	<input id="one">
	
	<button id="submit">SUBMIT</button>
	
<div id="output">
    <h1 id="name"></h1>
	<h1 id="birth_year"></h1>
	<h1 id="gender"></h1>
	<h1 id="height"></h1>
	<h1 id="mass"></h1>
	<h1 id="hair_color"></h1>
	<h1 id="eye_color"></h1>
	<h1 id="skin_color"></h1>		
		</div>
</div>
	
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
    <script  src="./script.js"></script>

</body>
</html>
              
            
!

CSS

              
                
body {
	background:url('https://thumbs.gfycat.com/LameUncomfortableBumblebee-size_restricted.gif') #000;  
	background-size: cover;
	background-repeat: no-repeat;
	overflow: hidden;
	height: 100%;
	width: 100%;
}

#wrapper {
	text-align: center;
	max-width: 960px;
	margin: 32px auto;
	color: white;
    font-family: 'Montserrat', sans-serif;
}

#toptext {
	margin-top: 0px;
	margin-bottom: 25px;
}

label {
  color: white;
  padding: 10px;
}

button {
  background-color: black;
  color: white;
  border: 2px solid yellow;
  border-radius: 12px;	
  font-size: 18px;
  margin-left: 5px
}

#controlbtn {
	margin-bottom: 15px; 
}

button:hover {
  background-color: yellow;
  color: black;  
  cursor: pointer;	
}
	
#logo {
	margin: 0 auto;
	max-width: 300px;
	max-height: 300px;
}

#output {
	color: yellow;
	transform: perspective(200px) rotateX(20deg);
	animation: crawl 25s linear;
	animation-fill-mode: forwards;
	animation-play-state: paused;	
  position: relative;
  z-index: -1; 
}

@keyframes crawl {
	0% {
		transform: perspective(200px) rotateX(20deg) translateY(425px);
		opacity: 1;
	}
	
	75% {
		opacity: 0;
	}
	
	100% {
		transform: perspective(200px) rotateX(20deg) translateY(-1200px);
		opacity: 0;
	}
}






              
            
!

JS

              
                window.onload = () =>  {
	
	function searchAPI() {
	let query = $("#one").val().toLowerCase();
	
	fetch(`https://swapi.dev/api/people/?search=${query}`
         )
		
		.then(res => res.json())
		.then((out) => {
	
		console.log(out)
		 let name = "NAME: " + out.results[0].name;
		 let height = "HEIGHT(CM): " + out.results[0].height;
		 let birth_year = "BIRTH YEAR: " + out.results[0].birth_year;
		 let gender = "GENDER: " + out.results[0].gender;
		 let hair_color = "HAIR COLOR: " + out.results[0].hair_color;
		 let eye_color = "EYE COLOR: " + out.results[0].eye_color;
		 let mass = "MASS(KG): " + out.results[0].mass;
		 let skin_color = "SKIN COLOR: " + out.results[0].skin_color;

		document.getElementById("name").innerHTML = name;
		document.getElementById("birth_year").innerHTML = birth_year;
		document.getElementById("height").innerHTML = height;
		document.getElementById("gender").innerHTML = gender;
		document.getElementById("hair_color").innerHTML = hair_color;
		document.getElementById("eye_color").innerHTML = eye_color;
		document.getElementById("mass").innerHTML = mass;
		document.getElementById("skin_color").innerHTML = skin_color;
		
document.getElementById('output').style.visibility = "visible";
    
    
	});
	}
	        $('#submit').click(function(){		
			searchAPI();
			$('#output').css("animation-play-state", "running");
		});
}

//RESETS ANIMATION ON CLICKING SUBMIT

$("#submit").click(function () {
  $("#output").hide();
  setTimeout(function () {
    $("#output").show();
  }, 10);
});

//CODE FOR MUSIC BUTTON

var musicbutton = document.getElementById('controlbtn');

var isPlaying = false;

musicbutton.addEventListener('click', function (){

	if(isPlaying == false){
		document.getElementById('swmusic').play();
		isPlaying = true;
		musicbutton.innerHTML = 'PAUSE MUSIC';

	} else{
		document.getElementById('swmusic').pause();
		isPlaying = false;
		musicbutton.innerHTML = 'PLAY MUSIC';
	}
 
})

              
            
!
999px

Console