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

            
              <html>
  <head>
    <meta charset="UTF-8">
    <title>KC Zoo App</title>
  </head>
  <body>
     <div class="header">
        <img src="https://www.kansascityzoo.org/wp-content/uploads/logo-header-01-1.png" alt="" />
      </div><!--End of header with logo-->
    <div class="myApp" id="animal_quiz">
 
      
      <div class="nav">
        <ul>
          <li class="navButton">Animal Quiz</li>
          <li class="navButton">Endangered Game</li>
          <li class="navButton">Matching Game</li>
        </ul>
      </div><!--end of green bar with navigation buttons-->
      
      <div class="animal">
        <div class="animalName">Zebu</div><!--<<<<put animal name here-->
        <div class="animalImage">
          <img class= "centered" src="https://s-media-cache-ak0.pinimg.com/736x/c3/46/dd/c346dd50add9266529f79f3e8e055bfc.jpg"/><!--<<<<<put image in here-->
        </div>
      </div><!--end of animal name and image section-->
      
      <div class="information bottom" id="information">
        <div class="location">Location: South Asia</div>
        <div class="diet">Diet: Grass, hay, grain</div>
        <div class="status">Status: Not Endangered</div>
        <div class="buttonHolder">
          <button onclick="question()">ANSWER QUESTION</button>
        </div>
      </div><!--end of animal info section-->
      
      <div class="quiz bottom" id="quiz">
        <div class="question">What does the zebu primarily eat?</div>
        <div class="choices">
          <ul>
            <li class="choiceA" onclick="guess('right')"><img src="http://supplementsinreview.com/wp-content/uploads/2016/11/wheat-grass-e1479644272193-100x100.jpg"/></li>
            <li class="choiceB" onclick="guess('wrong')"><img src="https://media.licdn.com/mpr/mpr/shrink_100_100/AAEAAQAAAAAAAAThAAAAJDMyNDY3NTY1LTA2YTktNGE5NC05YTgyLWE5YWY1NTVjZjZhYg.jpg" alt="" /></li>
            <li class="choiceC" onclick="guess('wrong')"><img src="http://www.kingkullen.com/wp-content/uploads/2012/03/img_catering-meat_08.jpg" alt="" /></li>
            <li class="choiceD" onclick="guess('wrong')"><img src="https://yt3.ggpht.com/-m_RHNjbksCI/AAAAAAAAAAI/AAAAAAAAAAA/RXYkONKrJa4/s100-c-k-no-mo-rj-c0xffffff/photo.jpg" alt="" /></li>
          </ul>
        </div>
      </div><!--end of quiz question section-->
      
      <div class="correct bottom" id="correct">
        <div class="feedback">CORRECT!</div>
        <div class="buttonHolder">
          <button onclick='info()'>Back to Info</button>
        </div>
      </div><!--end of correct section-->
      
      <div class="incorrect bottom" id="incorrect">
        <div class="feedback">Incorrect.</div>
        <div class="buttonHolder">
          <button onclick='question()'>Try Again</button>
        </div>
      </div><!--end of incorrect section-->
      
    </div><!--end of the app screen-->
    
    <div class="myApp" id="endangered_game"><!--e/s game starts here-->
      
      <div class="nav">
        <ul>
          <li class="navButton">Animal Quiz</li>
          <li class="navButton">Endangered Game</li>
          <li class="navButton">Matching Game</li>
        </ul>
      </div><!--end of green bar with navigation buttons-->
      
      <div class="statusGame">
        <div class="gallery"><!--beginning of drag and drop gallery-->
          <!--add your images here-->
          <img src="https://a-z-animals.com/media/animals/images/100x100/zebra.jpg" alt="" class="choice safe" id="zebra_face" />
        </div><!--end of drag/drop- gallery-->
        <div class="answers">
          <div class="eDroppable droppable" id="eDroppable">Endangered:
            <ul></ul>
          </div>
          <div class="sDroppable droppable" id="sDroppable">Safe:
            <ul></ul>
          </div>
        </div>
      </div>
    </div>
    <div class="myApp" id="matching_game">
      
      <div class="nav">
        <ul>
          <li class="navButton">Animal Quiz</li>
          <li class="navButton">Endangered Game</li>
          <li class="navButton" id="play">PLAY</li>
        </ul>
      </div><!--end of green bar with navigation buttons-->
      
      <div class="matchGame">
        <div class="card elephant" id="elephant1"></div>
        <div class="card elephant" id="elephant2"></div>
        <div class="card tiger" id="tiger1"></div>
        <div class="card tiger" id="tiger2"></div>
        <div class="card turtle" id="turtle1"></div>
        <div class="card turtle" id="turtle2"></div>
      </div>
 
    </div>
  </body>
</html>
            
          
!

CSS

            
              body {
  font-family: "FFDinRound",helvetica,arial,sans-serif;
  font-size: 16px;
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  border: 1px solid black;
  max-width: 480px;
}

.buttonHolder {
  text-align: center;
  padding: 10px 0 10px 0;
}

button {
  background: #fff;
  font-family: "FFDinRound",helvetica,arial,sans-serif;
  font-size: 16px;
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  border-radius: 5px;
}

.header {
  overflow: hidden;
}

.nav {
  color: #fff;
  background: #3b8c3d;
  width: 100%;
  line-height: 50px;
}

.navButton {
  list-style: none;
  margin: 10px;
  padding: 0;
  display: inline;
  cursor: pointer;
}

.navButton:hover {
  color: blue;
}

.centered {
  display: block;
  margin: 10px auto 20px auto;
}

.animalName {
  text-align: center;
}

.information {
  padding: 20px;
}

.information div {
  margin-left: 50px;
  margin-top: 10px;
}

.bottom {
  height: 200px;
  color: #fff;
  background: #3b8c3d;
}

.quiz {
  display: none;
}

.question {
  text-align: center;
  padding-top: 20px;
}

.choices ul li {
  display: inline;
  margin-right: 25px;
}

.choices ul li:hover {
  color: blue;
}

.correct {
  display: none;
}

.incorrect {
  display: none;
}

.feedback {
  padding-top: 40px;
  text-align: center;
  font-size: 32px;
}

li img {
  height: 75px;
  width: 75px;
  border: 2px solid #3b8c3d;
}

li img:hover {
  border: 2px solid blue;
}

.statusGame {
  height: 500px;
}

.gallery {
  height: 60%;
}

.gallery img {
  float: left;
  margin-left: 28px;
  margin-right: 28px;
  margin-top: 23px;
  border: 1px solid black;
  opacity: .8;
}

.answers {
  height: 40%;
}

.droppable {
  float: left;
  margin-left: 58px;
  height: 150px;
  width: 150px;
  border: 2px solid black;
  text-align: center;
  font-size: 20px;
  word-wrap: break-word;
}

ul li {
  list-style: none;
  font-size: 14px;
  line-height: 1em;
}


.matchGame {
  padding-top: 20px;
  height: 500px;
  position: relative;
}

.card {
  border: 1px solid grey;
  margin: 0 0 10px 60px;
  height: 150px;
  width: 150px;
  float: left;
}

.elephant {
  background-image: url("http://worldelephantday.org/assets/elephants-150x150.jpg");
}

.tiger {
  background-image: url("http://backwallpapers.com/wp-content/uploads/2017/01/Tiger-Images-150x150.jpg")
}

.turtle {
  background-image: url("https://www.orbitz.com/blog/wp-content/uploads/2016/07/Nevis-turtle-by-Mario-Cisneros-150x150.png");
}

.faceDown {
   background-image: url("https://www.kansascityzoo.org/wp-content/uploads/logo-header-01-1.png");
}

#endangered_game {
  display: none;
}

#matching_game {
  display: none;
}
            
          
!

JS

            
              $('.navButton').on('click', function(){
  if(!$(this).attr("id")){
    var appName = $(this).text();
    appName = appName.toLowerCase();
    appName = appName.replace(" ", "_")
    $(".myApp").css("display", "none");
    $("#" + appName).css("display", "inline");
  }
});



var information = document.getElementById('information');
var quiz = document.getElementById('quiz');
var correct = document.getElementById('correct');
var incorrect = document.getElementById('incorrect');


function question() {
  incorrect.style.display = "none";
  information.style.display = "none";
  quiz.style.display = "block";
}

function guess(answer) {
  var answer = answer;
  quiz.style.display = 'none';
  if (answer === 'right'){
    correct.style.display = 'block';
  } else {
    incorrect.style.display = 'block';
  }
}

function info(){
  correct.style.display = "none";
  information.style.display = "block";
}

var dragging;
var correct= 0;

$(".choice").draggable({
  revert: true,
  start: function(event, ui){
   dragging = "#" + $(this).prop("id");
  }
});

$(".eDroppable").droppable({
  accept: ".endangered", 
  drop: function(event, ui){
      $(dragging).css("visibility", "hidden");
      var text = $(dragging).prop("id").replace("_", " ");
      $(".eDroppable ul").append("<li>" + text + "</li>");
      correct += 1;
      if(correct === 6){
        done();
      }
  }
});

$(".sDroppable").droppable({
  accept: ".safe", 
  drop: function(event, ui){
      $(dragging).css("visibility", "hidden");
      var text = $(dragging).prop("id").replace("_", " ");
      $(".sDroppable ul").append("<li>" + text + "</li>");
      correct += 1;
      if(correct === 6){
        done();
      }
  }
});

function done(){
  setTimeout(function(){
    alert("Your done message here!")
  }, 500)
}

var count = 0;
var firstCard;
var secondCard;
var matches = 0;

//this function will shuffle the cards each time
$.fn.shuffleChildren = function() {
    $.each(this.get(), function(index, el) {
        var $el = $(el);
        var $find = $el.children();
        $find.sort(function() {
            return 0.5 - Math.random();
        });
        $el.empty();
        $find.appendTo($el);
    });
};

//this is what happens when the PLAY button is pressed
$('#play').on("click", function(){
  //set the count of matched sets to 0
  matches = 0;
  //shuffle the cards
  $(".matchGame").shuffleChildren();
  //cover the cards images
  $(".card").addClass("faceDown");
  //and when the player clicks on a card...
  $(".card").on("click", function(){
    if(count < 2){
      //if 0 or 1 cards clicked, show card
      $(this).removeClass("faceDown");
      //if this is the first card...
      if (count === 0){
        //record which card by id
        firstCard = $(this).attr('id');
        count++;
      //if this is the second card...  
      } else if (count === 1){
        //record card by id...
        secondCard = $(this).attr('id');
        count++;
        //then see if the ids match...
        if (firstCard.substring(0, firstCard.length-1) === secondCard.substring(0, secondCard.length-1)) {
          //if they match, record it...
          matches+=1;
          //and disable click on matched cards
          $("#" + firstCard).off('click');
          $("#" + secondCard).off('click');
          //then reset the count and blank the card variables..
          count = 0;
          firstCard = "";
          secondCard = "";
          //then check to see if they have matched all sets...
          if(matches === 3){
            setTimeout(function(){
              //win message in pop-up box
              alert("You got them all!!")          
            }, 300);
          } 
          
        //BUT if they don't match...
        } else {
          //start card count over again...
          count = 0;
          //then set a timer to...
          setTimeout(function(){
            //cover up the clicked cards again.
            if (firstCard !== "") $("#" + firstCard).addClass("faceDown");
            if (secondCard !== "") $("#" + secondCard).addClass("faceDown");
            firstCard = "";
            secondCard = "";
          }, 1000)
        }
      }
    } 
  });
});


            
          
!
999px

Console