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

              
                
<html>
<head>
    <title>Feed da Panda</title>
  </head>
<body>
    <div class="sky"><div class="sun"></div></div>
    <div class="grass">
      <button class ="feed" onclick=""> Feed da Panda </button>
  <br>
      
      <!-- Go Home, Panda button will go on this line, remove this comment and replace with button code -->
        <div class="body1">
            <div class="face">
                <div class="ear-left"></div>
                <div class="ear-right"></div>
                <div class="eye-right">
                    <div class="d1"></div>
                    <div class="d2"></div>
                </div>
                <div class="eye-left">
                    <div class="d3"></div>
                    <div class="d4"></div>
                </div>
                <div class="nose"></div>
            </div>
            <div class="hand-left"></div>
            <div class="hand-right"></div>
            <div class="leg-left"></div>
            <div class="leg-right"></div>
        </div>
      <div class = "munchie"> *munch munch munch* </div>
        <div class="bamboo">
    <div class="s1">
        <div class="leaf1"></div>
        <div class="leaf2"></div>
        <div class="leaf3"></div>
    </div>
    <div class="s2"></div>
    <div class="s3"></div>
    <div class="s4"></div>
</div>
   </div>

</body>
</html>
              
            
!

CSS

              
                body{
           margin:0%; 
           overflow-x: hidden;
        }
.body1{
            position:relative;
            bottom:150px;
            left:40%;
            width:80px;
            height:120px;
            border-style:solid;
            border-width: 5px;
            border-color: #000000;
            border-radius:30%;
            background-color: #ffffff;
            

        }
        .face{
            position:relative;
            bottom:30px;
            right:20px;
            border-style:solid;
            border-width: 5px;
            border-color: #000000;
            width:110px;
            height:90px;
            border-radius:45%;
            background-color:#ffffff;
            animation-name: wobble;
            animation-duration: 1.5s;
            animation-iteration-count: infinite;
        }
        @keyframes wobble{
            0%{
                transform:rotate(-20deg);

            }
            50%{
                transform: rotate(20deg);
            }
            100%{
                transform: rotate(-20deg);
            }
        }
        .ear-left{
            width: 40px;
            height: 25px; 
            background-color:#000000;
            transform: rotate(145deg);

             border-radius: 0 0 90px 90px;
             position: relative;
             bottom:15px;
             right:10px;
        }
        .ear-right{
            width: 40px;
            height: 25px; 
            background-color:#000000;
            transform: rotate(-145deg);

             border-radius: 0 0 90px 90px;
             position: relative;
             bottom:40px;
             left:80px;
        }
        .eye-left{
            position: relative;
            width:28px;
            height:33px;
            background-color: #000000;
            border-radius: 50%;
            bottom:63px;
            left:72px;
            transform:rotate(-25deg);
        }
        .eye-right{
            position: relative;
            width:28px;
            height:33px;
            background-color: #000000;
            border-radius: 50%;
            bottom:30px;
            left:10px;
            transform:rotate(25deg);
        }
        .d1{
            width:10px;
            height:10px;
            top:8px;
            left:10px;
            border-radius:50%;
            background-color:#ffffff;
            position: relative;
        }
        .d2{
            width:5px;
            height:5px;
            top:11px;
            left:10px;
            border-radius:50%;
            background-color:#ffffff;
            position: relative;
        }
        .d3{
            width:10px;
            height:10px;
            top:8px;
            left:9px;
            border-radius:50%;
            background-color:#ffffff;
            position: relative;
        }
        .d4{
            width:5px;
            height:5px;
            top:11px;
            left:14px;
            border-radius:50%;
            background-color:#ffffff;
            position: relative;
        }
        .nose{
            width:15px;
            height:8px;
            border-radius: 15px;
            background-color: #000000;
            position: relative;
            bottom:65px;
            left:48px;
        }
        .hand-left{
            position:relative;
            width:25px;
            background-color: #000000;
            height:43px;
            border-radius:30px 30px 30px 30px;
            transform: rotate(90deg);
            bottom:52px;
            right:33px;
            animation-name: handsl;
            animation-duration: 1.5s;
            animation-iteration-count: infinite;
            

            }    
            @keyframes handsl{
                0%{
                    transform: rotate(150deg);
                }
                50%{
                    transform:rotate(90deg);
                }
                100%{
                    transform: rotate(150deg);
                }
            }
        .hand-right{
            position:relative;
            width:25px;
            background-color: #000000;
            height:43px;
            border-radius:30px 30px 30px 30px;
            transform: rotate(-90deg);
            bottom:92px;
            left:89px;
            animation-name: hands2;
            animation-duration: 1.5s;
            animation-iteration-count: infinite;
        }
        @keyframes hands2{
                0%{
                    transform: rotate(-150deg);
                }
                50%{
                    transform:rotate(-90deg);
                }
                100%{
                    transform: rotate(-150deg);
                }
            }
        .leg-left{
            position:relative;
            width:17px;
            background-color: #000000;
            height:25px;
            border-radius:00px 0px 30px 30px;
            
            bottom:65px;
            left:15px;
        }    
        .leg-right{
            position:relative;
            width:17px;
            background-color: #000000;
            height:25px;
            border-radius:00px 0px 30px 30px;
            
            bottom:90px;
            left:49px;
        }
        .grass{
            position: absolute;
            top:350px;
            background-color:#00ff00;
            width: 100%;
            height:200px;
        }
        .sky{
            position: absolute;
            background-color:#66ffff ;
            width:100%;
            height: 400px;
            animation-name: chnge;
            animation-duration:20s;
            animation-iteration-count: infinite;
        }
        @keyframes chnge{
            0%{
                background-color:#66ffff ;
            }
            50%{
                background-color:#2e2eb8;
            }
            100%{
                background-color:#66ffff ;
            }
        }
        .munchie{
            position: relative;
            left:56%;
            bottom:340px;
            opacity: 0;
            font-size: 30px;
      }
        .bamboo{
            position: relative;
            left:56%;
            bottom:340px;
            display:none; 

        }
        .s1{
            position: relative;
            width:12px;
            height:48px;
            background-color:#009900;
            bottom:-2px;

        }
        .s2{

            position: relative;
            width:12px;
            height: 48px;
            background-color:#009900;
            bottom:-10px;

        }
        .s3{
            position: relative;
            width:12px;
            bottom:-18px;
            height: 48px;
            background-color:#009900;

        }
        .s4{
            position: relative;
            width:12px;
            height:48px;
            bottom:-25px;
            background-color:#009900;

        }
        .leaf1{
            position: relative;
            width: 45px; height: 45px;
              background-color:#00cc00;
              border-radius: 100px 0px; 
              left:12px;
              animation-name: lf;
              animation-duration: 1.5s;
              animation-iteration-count: infinite;
        }
        .leaf2{
            position: relative;
            width: 45px; height: 45px;
              background-color:#00cc00;
              border-radius: 0px 100px 0px 100px; 
              top:20px;
              right:45px;
              animation-name: lff;
              animation-duration: 1.5s;
              animation-iteration-count: infinite;
              
        }
        .leaf3{
            position: relative;
            width: 45px; height: 45px;
              background-color:#00cc00;
              border-radius: 100px 0px;
              top:35px;
              left:12px;
              animation-name: lf;
              animation-duration: 1.5s;
              animation-iteration-count: infinite;
        }
        @keyframes lf{
            0%{
                transform: rotate(10deg);
            }
            50%{
                transform: rotate(0deg);
            }
            100%{
                transform: rotate(10deg);
            }
        }
        @keyframes lff{
            0%{
                transform: rotate(-10deg);
            }
            50%{
                transform: rotate(0deg);
            }
            100%{
                transform: rotate(-10deg);
            }
        }
        .sun{
            position: relative;
            left:10%;
            top:30px;
            width:80px;
            height: 80px;
            border-radius: 50%;
            background-color: #ffbf00;
            animation-name:sn;
            animation-duration:20s;
            animation-iteration-count: infinite;
        
        }
        @keyframes sn{
            0%{
                border-radius: 50%;
                background-color: #ffbf00;
            }
            50%{
                 background-color: #2e2eb8;
                 border-radius: 50%;
                 box-shadow: 15px 15px 0 0 white;
                 transform: rotateY(180deg) translateX(-50px);
               
            }
            100%{
                border-radius: 50%;
                background-color: #ffbf00;
            }
        }

.feed, .home{
  font-size: 30px; 
  padding: 0%;
  margin-left: 5%;
  margin-top: 2%;
  height: 20%;
  width: 20%;
}

@keyframes goToFood{
  0%{
    left: 40%;
  }
  100%{
    left: 54%;
  }
}

@keyframes munch{
  0%{
    opacity: 1;
  }
  50%{
    opacity: .7;
  }
  100%{
    opacity: 0;
  }
}

@keyframes munchieFade{
  0%{
    opacity: 0;
    left: 58%;
  }
  50%{
    opacity: 1
  }
  100%{
    opacity: 0;
    left: 80%;
    bottom: 600px;
  }
}

@keyframes goHome{
  0%{
    left: 54%;
  }
  100%{
    left: 40%;
  }
}
              
            
!

JS

              
                // Note: if you are viewing this pen on the DDEM website you may need to zoom out by clicking ".5x" or one of the other options at the bottom of the results pane

// Write a function to feed da panda! Pandas eat bamboo.
// First, outside of the function, declare a new boolean variable that represents feeding time, that is false.
// To feed the panda, you have to select the bamboo div from the HTML and store it in a variable
// The function that feeds the panda will make the bamboo appear by including the following line of code:
      // variableNameStoringBambooDiv.style.cssText = "display: block;"; 
      // where you will replace variableNameStoringBambooDiv with whatever your variable name is.
// Within the function, change the feeding time boolean to true.
// Within the function, invoke the pandaEat function, which has already been written
// Within the function, print a statement to the console to know that the function has executed
// Program the "Feed da Panda" button to execute the function you wrote whenever it is clicked


// If programmed correctly:
// 1. After you click the 'Feed da Panda' button, the bamboo will appear and the panda will walk to it
// 2. The panda will eat the bamboo and it will disappear segment by segment, while making munching sounds (you can't hear the sounds, the words appear on screen)


// Finally, add a button in the HTML that displays the text "Go Home, Panda!!!"
// Give the button a class of "home"
// When the button is clicked, it should execute the returnPanda function, which has already been written
// The panda will return to its original position










// Pre-written functions:

function pandaEat() { 
  if(feedingTime){
    let panda = document.querySelector('.body1');
    panda.style.cssText = "animation-name: goToFood; animation-duration:5s; animation-iteration-count: 1; animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards;"
    let munchmunch = document.querySelector('.munchie');
    munchmunch.style.cssText = "animation-name: munchieFade; animation-duration:4s; animation-iteration-count: 3;";
    let bamboo1 = document.querySelector('.s1');
    bamboo1.style.cssText = "animation-name: munch; animation-duration:8s; animation-iteration-count: 1; animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards;"; 
    let bamboo2 = document.querySelector('.s2');
    bamboo2.style.cssText = "animation-name: munch; animation-duration:9s; animation-iteration-count: 1; animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards;"; 
    let bamboo3 = document.querySelector('.s3');
    bamboo3.style.cssText = "animation-name: munch; animation-duration:10s; animation-iteration-count: 1; animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards;"; 
    let bamboo4 = document.querySelector('.s4');
    bamboo4.style.cssText = "animation-name: munch; animation-duration:13s; animation-iteration-count: 1; animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards;"; 
  } 
}

function returnPanda(){
  let panda = document.querySelector('.body1');
  panda.style.cssText = "animation-name: goHome; animation-duration:5s; animation-iteration-count: 1; animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards;"
}
              
            
!
999px

Console