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

              
                <img src="https://upload.wikimedia.org/wikipedia/commons/9/98/International_Pok%C3%A9mon_logo.svg" class="title"/>
<h1>Open the Pokéball to Reveal</br> the Pokémon Sprite Inside.</h1>

<h2 id="pokeName" class="pokeName"></h2>
<div id="pokemon"></div>



              
            
!

CSS

              
                
body {
  font-family: 'Roboto', sans-serif;
  margin:0;
  padding:0;
  background-color: #a5d6a7; 
}

.title {
  width: 300px;
  display:flex;
  margin:0 auto;
  margin-top: 2rem;
}
h1 {
 font-size:22px;
  font-weight:normal;
  text-align:center; 
}

h2 {
 text-align: center;
 font-size:24px;
}

.pokeName {
  text-transform: capitalize;
  margin-top:2rem;
  margin-bottom:0;
  padding-bottom: 0;
  transition-timing-function: ease-in;
  transition-property: opacity;
  transition-duration: 200s;
}

div.pokemon {
  text-align: center;
}

#pokemon {
  display:flex;
  flex-direction:column;
  position: relative;
    top:4rem;
  padding:2rem;
  width: 320px;
  margin:0 auto;
  -webkit-transform: translate3d(0px,0px,0px);
  
}

.halfCircleTop {
  height:165px;
  width:307px;
  border:2px solid #0f0f0f;
  border-botom: 10px solid #0f0f0f;
  border-radius:150px 150px 0 0 ;
  background:red;
  position:relative;
  bottom: 8rem;
}

.halfCircleBottom{
  height:135px;
  width:307px;
  border:2px solid #0f0f0f;
  border-top: 20px solid #0f0f0f;
  border-radius: 0 0 150px 150px;
  background:white;
  position:relative;
  bottom:9rem;  
}

.centerCircle {
  cursor: pointer;
	width: 70px;
	height: 70px;
	background: white;
  border:6px solid #0f0f0f;
  z-index:9998;
	-moz-border-radius: 50px;
	-webkit-border-radius: 50px;
	border-radius: 50px;
  position: relative;
    left: 7.5rem;
    bottom: -4.25rem;
}
.centerCircle:hover {
   box-shadow: inset 0 0 10px #000000;
}


#sprites {
  z-index:9999;
  height: 500%;
  width: 500%;
}

/* CSS Animation Keyframes  */
@-webkit-keyframes pokemonAnimation {
   0% {
    left:0px;
    bottom:0px;
  }
  
  25% {
    left:50px;
    bottom:50px;
  }
  
  50% {
    right:50px;
    bottom:0px;
  }
  
  75% {
    right:100px;
    bottom:50px;
  }

  100% {
    left:0px;
    bottom:0px;
  }
}

@-webkit-keyframes pokeNameAnimation {
  0% {
    opacity:0;
  }
  
  25% {
    opacity:25%;
  }
  
  50% {
    opacity:50%;
   
  }
  
  75% {
    opacity:75%;

  }

  100% {
    opacity:100%;
    top:2rem;
   
  }
}


#sprites {
  position:relative;
  -webkit-animation-name: pokemonAnimation;
  -webkit-animation-duration: 6s;
  -webkit-animation-timing-function: ease-in;
  -webkit-animation-direction: alternate;
}

.pokename {
  position:relative;
  -webkit-animation-name: pokeNameAnimation;
  -webkit-animation-duration: 7s;
  -webkit-animation-timing-function: ease-in;
}


              
            
!

JS

              
                //Global Variables
var root = "https://accesscontrolalloworiginall.herokuapp.com/https://pokeapi.co/api/v2/";
var pokemon;
var pokeName;
var html =
  "<div class='pokemon centerCircle images'></div><div class='halfCircleTop'></div><div class='halfCircleBottom'></div>";


function shakeShakeShake() {
  $("#pokemon").effect("shake", 2000);
}

function choosePokemon(pokeList) {
  for (var i = 0; i < 1; i++) {
    var randomPokemon = pokeList[Math.floor(Math.random() * pokeList.length)];
    pokeName = randomPokemon.name;
  }
  return pokeName;
}

$("#pokemon").html(html);

$(".centerCircle").click(function(event) {
  $('#pokeName').empty();
  $("#sprites").parent().empty();
  shakeShakeShake();
  $.ajax({
    url: root + "pokemon/?limit=811",
    method: "GET"
  }).then(function(data) {
    pokemon = data.results;
    var myPokemon = choosePokemon(pokemon);
    console.log(myPokemon + " is my pokemon");
    pokeImage(myPokemon);
    $("#pokeName").html(myPokemon);
    $("#pokeName").data("pokemon", myPokemon);
  });
});

function pokeImage(pokeName) {
  var myPokemon = pokeName;
  var url = root + "pokemon/" + myPokemon + "/";
  var poke = $("div.images");

  $.ajax({
    url: url,
    method: "GET"
  }).then(function(data) {
    var pokeImg = data.sprites.front_default;
    console.log("pokeImg is " + pokeImg);

    var htmlImg = "<img id='sprites' src='" + pokeImg + "'/>";

    poke.html(htmlImg);
  });
}
              
            
!
999px

Console