cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="wrap">
			<section class="intro">
				<h1 class="title">Hello! Your pet has been waiting for you for so long!</h1>
				<p class="description">First of all, your pet wants to play with you. If you don't play with it, it will feel lonely and start getting sad. Also, you should feed your pet, when it becomes hungry, and take it to doctor, when it becomes ill. Like everyone in this world, pet is growing and getting old. Nothing can do with it. Just take care of it!</p>
			</section>			
			<section class="home">
				<div class="cat child">
					<div class="head">
						<p class="ears"><span class="left-ear"></span><span class="right-ear"></span></p>
						<p class="eyes"><span class="left-eye"></span><span class="right-eye"></span></p>
						<p class="nose"></p>
						<p class="mouth">D</p>
					</div>
					<div class="body">
						<div class="left-arm"></div>
						<div class="right-arm"></div>
						<div class="left-leg"><span class="foot"></span></div>
						<div class="right-leg"><span class="foot"></span></div>
						<div class="tail">S</div>
					</div>
				</div>
			</section>
			<section class="configurations">
				<p>Configurations:</p>
				<button class="button" id="play">Play with your pet</button>
				<button class="button" id="feed">Feed your pet</button>
				<button class="button" id="doctor">Take your pet to doctor</button>
			</section>
		</div>
            
          
!
            
              html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  font-size: 100%;
  vertical-align: baseline;
}

html {
  line-height: 1;
}

ol, ul {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

caption, th, td {
  text-align: left;
  font-weight: normal;
  vertical-align: middle;
}

q, blockquote {
  quotes: none;
}

q:before, q:after, blockquote:before, blockquote:after {
  content: "";
  content: none;
}

a img {
  border: none;
}

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary {
  display: block;
}

body {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  min-width: 800px;
  min-height: 600px;
  background-color: #a5dff5;
  z-index: -1;
}

.wrap {
  min-width: 800px;
  min-height: 600px;
  width: 100%;
  height: 100%;
  z-index: 1;
  font-family: arial;
}

.home {
  min-height: 250px;
  min-width: 300px;
  width: 25%;
  height: 35%;
  background-color: #d3d3d3;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  -ms-border-radius: 10px;
  -o-border-radius: 10px;
  border-radius: 10px;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -35%;
  margin-top: -15%;
  -webkit-box-shadow: inset 5px 5px 5px 0 #333333, inset -3px -3px 0 0 #999999;
  -moz-box-shadow: inset 5px 5px 5px 0 #333333, inset -3px -3px 0 0 #999999;
  box-shadow: inset 5px 5px 5px 0 #333333, inset -3px -3px 0 0 #999999;
  position: relative;
}

.home:after {
  content: "";
  display: block;
  background: #de0000;
  width: 160%;
  height: 150%;
  position: relative;
  position: absolute;
  left: -30%;
  top: -25%;
  -webkit-border-radius: 1500px;
  -moz-border-radius: 1500px;
  -ms-border-radius: 1500px;
  -o-border-radius: 1500px;
  border-radius: 1500px;
  z-index: -1;
  -webkit-box-shadow: inset -10px -10px 45px 0 #333333, inset 10px 10px 75px 0 #f5c6c6, 10px 10px 35px -10px black;
  -moz-box-shadow: inset -10px -10px 45px 0 #333333, inset 10px 10px 75px 0 #f5c6c6, 10px 10px 35px -10px black;
  box-shadow: inset -10px -10px 45px 0 #333333, inset 10px 10px 75px 0 #f5c6c6, 10px 10px 35px -10px black;
}

@keyframes happy {
  0% {
    right: -5px;
    top: -90px;
    transform: rotate(-10deg);
  }

  25% {
    right: -5px;
    top: -90px;
    transform: rotate(0deg);
  }

  50% {
    right: -15px;
    top: -90px;
    transform: rotate(-10deg);
  }

  75% {
    right: -15px;
    top: -90px;
    transform: rotate(0deg);
  }

  100% {
    right: -5px;
    top: -90px;
    transform: rotate(-10deg);
  }
}

@-webkit-keyframes happy {
  0% {
    right: -5px;
    top: -90px;
    -webkit-transform: rotate(-10deg);
  }

  25% {
    right: -5px;
    top: -90px;
    -webkit-transform: rotate(0deg);
  }

  50% {
    right: -15px;
    top: -90px;
    -webkit-transform: rotate(-10deg);
  }

  75% {
    right: -15px;
    top: -90px;
    -webkit-transform: rotate(0deg);
  }

  100% {
    right: -5px;
    top: -90px;
    -webkit-transform: rotate(-10deg);
  }
}

@-moz-keyframes happy {
  0% {
    right: -5px;
    top: -90px;
    -moz-transform: rotate(-10deg);
  }

  25% {
    right: -5px;
    top: -90px;
    -moz-transform: rotate(0deg);
  }

  50% {
    right: -15px;
    top: -90px;
    -moz-transform: rotate(-10deg);
  }

  75% {
    right: -15px;
    top: -90px;
    -moz-transform: rotate(0deg);
  }

  100% {
    right: -5px;
    top: -90px;
    -moz-transform: rotate(-10deg);
  }
}

.cat {
  width: 300px;
  height: 250px;
  position: absolute;
  z-index: 2;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -180px;
  margin-top: -125px;
  -webkit-transition: 3s;
  -moz-transition: 3s;
  -o-transition: 3s;
  transition: 3s;
}

.cat .head {
  width: 25%;
  height: 30%;
  -webkit-border-radius: 100%;
  -moz-border-radius: 100%;
  -ms-border-radius: 100%;
  -o-border-radius: 100%;
  border-radius: 100%;
  background: #eaa91d;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -30%;
  margin-top: -25%;
  border: 2px dotted #eaa91d;
  background-clip: padding-box;
  -moz-background-clip: padding-box;
  z-index: 3;
  -webkit-box-shadow: 1px 3px 10px -5px #333333;
  -moz-box-shadow: 1px 3px 10px -5px #333333;
  box-shadow: 1px 3px 10px -5px #333333;
  -webkit-transition: 3s;
  -moz-transition: 3s;
  -o-transition: 3s;
  transition: 3s;
}

.cat .eyes span {
  width: 20%;
  height: 20%;
  -webkit-border-radius: 100%;
  -moz-border-radius: 100%;
  -ms-border-radius: 100%;
  -o-border-radius: 100%;
  border-radius: 100%;
  background-color: #84e1ff;
  position: absolute;
  font-size: 15px;
  border: 1px solid #000;
}

.cat .eyes span:after {
  content: "";
  width: 50%;
  height: 50%;
  -webkit-border-radius: 100%;
  -moz-border-radius: 100%;
  -ms-border-radius: 100%;
  -o-border-radius: 100%;
  border-radius: 100%;
  background-color: #000;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -25%;
  margin-top: -25%;
}

.cat .left-eye {
  left: 20%;
  top: 25%;
}

.cat .right-eye {
  right: 20%;
  top: 25%;
}

.cat .nose {
  font-weight: bold;
  text-align: center;
  margin-top: 40%;
  width: 0;
  border-style: solid;
  border-width: 10px;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -10px;
  margin-top: 0;
  border-color: #000 transparent transparent transparent;
}

.cat .mouth {
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  -o-transform: rotate(90deg);
  transform: rotate(90deg);
  font-weight: bold;
  font-family: arial;
  font-size: 27px;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -10px;
  margin-top: 7px;
}
/* line 222, ../sass/main.scss */
.cat .ears span {
  border-style: solid;
  border-width: 35px 10px;
  border-color: transparent transparent #eaa91d transparent;
  position: absolute;
  margin-top: -60px;
  -webkit-transition: 3s;
  -moz-transition: 3s;
  -o-transition: 3s;
  transition: 3s;
}

.cat .left-ear {
  -webkit-transform: rotate(-25deg);
  -moz-transform: rotate(-25deg);
  -ms-transform: rotate(-25deg);
  -o-transform: rotate(-25deg);
  transform: rotate(-25deg);
  left: -5px;
}

.cat .right-ear {
  right: -5px;
  -webkit-transform: rotate(25deg);
  -moz-transform: rotate(25deg);
  -ms-transform: rotate(25deg);
  -o-transform: rotate(25deg);
  transform: rotate(25deg);
}

.cat .body {
  width: 70%;
  height: 35%;
  -webkit-border-radius: 100px;
  -moz-border-radius: 100px;
  -ms-border-radius: 100px;
  -o-border-radius: 100px;
  border-radius: 100px;
  background: #eaa91d;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -30%;
  margin-top: -5%;
  border: 2px dotted #eaa91d;
  background-clip: padding-box;
  -webkit-box-shadow: 1px 3px 10px -5px #333333;
  -moz-box-shadow: 1px 3px 10px -5px #333333;
  box-shadow: 1px 3px 10px -5px #333333;
  -webkit-transition: 3s;
  -moz-transition: 3s;
  -o-transition: 3s;
  transition: 3s;
}

.cat .left-arm, .cat .right-arm, .cat .left-leg, .cat .right-leg {
  width: 10%;
  height: 80%;
  -webkit-border-radius: 100%;
  -moz-border-radius: 100%;
  -ms-border-radius: 100%;
  -o-border-radius: 100%;
  border-radius: 100%;
  background: #eaa91d;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -40%;
  margin-top: 5%;
  border: 2px dotted #eaa91d;
  background-clip: padding-box;
  z-index: 1;
  -webkit-box-shadow: 1px 3px 10px -5px #333333;
  -moz-box-shadow: 1px 3px 10px -5px #333333;
  box-shadow: 1px 3px 10px -5px #333333;
  -webkit-transition: 3s;
  -moz-transition: 3s;
  -o-transition: 3s;
  transition: 3s;
}

.cat .left-arm {
  z-index: -1;
}

.cat .right-arm {
  margin-left: -25%;
}

.cat .left-leg {
  margin-left: 15%;
  z-index: -1;
}

.cat .right-leg {
  margin-left: 30%;
}

.cat .tail {
  color: #eaa91d;
  font-size: 150px;
  font-weight: bold;
  position: absolute;
  text-shadow: 1px 3px 5px #999999;
  z-index: -1;
  right: -5px;
  top: -90px;
  -webkit-transform: rotate(-10deg);
  -webkit-transition: 3s;
  -moz-transition: 3s;
  -o-transition: 3s;
  transition: 3s;
}


.child {
  -webkit-transform: scale(0.4, 0.4);
  -moz-transform: scale(0.4, 0.4);
  -ms-transform: scale(0.4, 0.4);
  -o-transform: scale(0.4, 0.4);
  transform: scale(0.4, 0.4);
}

.young {
  -webkit-transform: scale(0.7, 0.7);
  -moz-transform: scale(0.7, 0.7);
  -ms-transform: scale(0.7, 0.7);
  -o-transform: scale(0.7, 0.7);
  transform: scale(0.7, 0.7);
}

.adult {
  -webkit-transform: scale(1, 1);
  -moz-transform: scale(1, 1);
  -ms-transform: scale(1, 1);
  -o-transform: scale(1, 1);
  transform: scale(1, 1);
}

.dead {
  display: none;
}

.old > div, .old .left-leg, .old .right-leg, .old .left-arm, .old .right-arm {
  background-color: #aaa !important;
}

.old .tail, .old .ears span {
  color: #aaa;
  border-bottom-color: #aaa !important;
}

.cat.happy .tail {
  animation: happy 1s infinite;
  -moz-animation: happy 1s infinite;
  -webkit-animation: happy 1s infinite;
}

.cat.satisfied .tail {
  animation: happy 5s infinite;
  -moz-animation: happy 5s infinite;
  -webkit-animation: happy 5s infinite;
}

.cat.normal .left-ear, .cat.ill .left-ear {
  -webkit-transform: rotate(-55deg);
  -moz-transform: rotate(-55deg);
  -ms-transform: rotate(-55deg);
  -o-transform: rotate(-55deg);
  transform: rotate(-55deg);
  margin-left: -10px;
  margin-top: -45px;
}

.cat.normal .right-ear, .cat.ill .right-ear {
  -webkit-transform: rotate(55deg);
  -moz-transform: rotate(55deg);
  -ms-transform: rotate(55deg);
  -o-transform: rotate(55deg);
  transform: rotate(55deg);
  margin-right: -10px;
  margin-top: -45px;
}

.ill > div, .ill .left-leg, .ill .right-leg, .ill .left-arm, .ill .right-arm {
  background-color: #059813 !important;
}

.ill .tail, .ill .ears span {
  color: #059813;
  border-bottom-color: #059813 !important;
}

.empty .body {
  width: 70%;
  height: 30%;
}

.empty .left-arm, .empty .right-arm, .empty .left-leg, .empty .right-leg {
  height: 100%;
}

.starving .body {
  width: 70%;
  height: 25%;
}

.starving .left-arm, .starving .right-arm, .starving .left-leg, .starving .right-leg {
  height: 130%;
}

.satisfied .mouth, .neutral .mouth, .sad .mouth {
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -5px;
  margin-top: 7px;
}

.satisfied .tail, .neutral .tail, .sad .tail, .angry .tail {
  right: 10px;
}

.angry .mouth {
  -webkit-transform: rotate(270deg);
  -moz-transform: rotate(270deg);
  -ms-transform: rotate(270deg);
  -o-transform: rotate(270deg);
  transform: rotate(270deg);
}

.angry .eyes span {
  background-color: #f00;
}

.intro {
  position: absolute;
  top: 3%;
  right: 1%;
  width: 35%;
  color: #333;
  text-shadow: 1px 1px 1px #fff;
  font-size: 15px;
}

.intro .title {
  font-size: 30px;
  font-weight: bold;
  margin: 0 0 50px 0;
}

.configurations {
  position: absolute;
  right: 3%;
  bottom: 10%;
  color: #333;
  text-shadow: 1px 1px 1px #fff;
  font-size: 15px;
}

.button {
  padding: 0 20px;
  height: 40px;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  -ms-border-radius: 10px;
  -o-border-radius: 10px;
  border-radius: 10px;
  background-color: #2527D4;
  display: block;
  font-size: 13px;
  color: #eee;
  border: none;
  -webkit-box-shadow: inset 1px 1px 3px 0 #9293d5, inset -1px -1px 3px 0 #333333;
  -moz-box-shadow: inset 1px 1px 3px 0 #9293d5, inset -1px -1px 3px 0 #333333;
  box-shadow: inset 1px 1px 3px 0 #9293d5, inset -1px -1px 3px 0 #333333;
  text-shadow: 1px 1px 1px black;
  margin: 10px 5px 15px 5px;
  cursor: pointer;
  font-weight: bold;
}

.button:hover {
  background-color: #2325B8;
}

.button:active {
  background-color: #2325B8;
  -webkit-box-shadow: inset 1px 1px 5px 0 #333333, inset -1px -1px 5px 0 #333333;
  -moz-box-shadow: inset 1px 1px 5px 0 #333333, inset -1px -1px 5px 0 #333333;
  box-shadow: inset 1px 1px 5px 0 #333333, inset -1px -1px 5px 0 #333333;
  text-shadow: -1px -1px 1px black;
}

            
          
!
            
              /*object pet*/
function listen(evnt, elem, func) {
  if (elem.addEventListener) { // W3C DOM
    elem.addEventListener(evnt,func,false);}
  else if (elem.attachEvent) { // IE DOM
    var r = elem.attachEvent("on" + evnt, func);
    return r;
  }
}

function Pet(name, mood, hunger, age, health) {
	this.mood = mood;
	this.hunger = hunger;
	this.age = age;
	this.health = health;
	this.name = name;
    this.indexAge = 0;
    this.indexMood = 0;
    this.indexHunger = 0;
    this.indexHealth = 0;
    this.element = document.getElementsByClassName(this.name);
}

Pet.prototype.setMood = function() {
    this.element[0].className = this.name + " " + this.mood + " " + this.hunger + " " + this.age + " " + this.health;
}

Pet.prototype.life = function() {  

    var mouth = document.getElementsByClassName("mouth")[0];
    var tail = document.getElementsByClassName("tail")[0]
    var objectName = this;    

    function gettingOlder() {
        objectName.indexAge++;
        objectName.age = configs.ages[objectName.indexAge];
        objectName.setMood();        
        if (objectName.element[0].className.indexOf("dead") == -1 ) {
            setTimeout(gettingOlder, 80000);
        };
    }
   

    function gettingSad() {
        objectName.indexMood++;
    	objectName.mood = configs.moods[objectName.indexMood];
        objectName.setMood();        

        if (objectName.element[0].className.indexOf("satisfied") > -1 ) {
	    	mouth.innerHTML = ")";
	    };

	    if (objectName.element[0].className.indexOf("neutral") > -1 ) {
	    	mouth.innerHTML = "|";
	    	tail.innerHTML = "I";
	    };

	    if (objectName.element[0].className.indexOf("sad") > -1 ) {
	    	mouth.innerHTML = "(";
	    };

	    if (objectName.element[0].className.indexOf("angry") > -1 ) {
	    	mouth.innerHTML = "D";
	    };

        if (objectName.element[0].className.indexOf("dead") == -1 ) {
            setTimeout(gettingSad, 10000);
        };
       
    }

    function gettingIll() {
        objectName.indexHealth++;
        objectName.health = configs.healthTypes[objectName.indexHealth];
        objectName.setMood();        

        if (objectName.element[0].className.indexOf("dead") == -1 ) {
            setTimeout(gettingIll, 50000);
        };
    }

    function gettingHungry() {
        objectName.indexHunger++;
        objectName.hunger = configs.feedTypes[objectName.indexHunger];
        objectName.setMood();

        if (objectName.element[0].className.indexOf("dead") == -1 ) {
            setTimeout(gettingHungry, 30000);
        };
    }

    function play() {
        if (objectName.element[0].className.indexOf("dead") == -1 ) {
            objectName.indexMood = 0;
            objectName.mood = configs.moods[objectName.indexMood];
            objectName.setMood();
            mouth.innerHTML = "D";
            tail.innerHTML = "S";
        }       
    }

    function feed() {
        if (objectName.element[0].className.indexOf("dead") == -1 ) {
            objectName.indexHunger = 0;
            objectName.hunger = configs.feedTypes[objectName.indexHunger];
            objectName.setMood();
        }
    }

    function takeToDoctor() {
        if (objectName.element[0].className.indexOf("dead") == -1 ) {
            objectName.indexHealth = 0;
            objectName.health = configs.healthTypes[objectName.indexHealth];
            objectName.setMood();
        }
    }

    setTimeout(gettingOlder, 80000);
    setTimeout(gettingSad, 10000);
    setTimeout(gettingIll, 50000);
    setTimeout(gettingHungry, 30000);

    listen('click', document.getElementById('play'), play);

    listen('click', document.getElementById('feed'), feed);

    listen('click', document.getElementById('doctor'), takeToDoctor);

}

/*setting options for pet's conditions*/

var configs = {
	moods: ["happy", "satisfied", "neutral", "sad", "angry", "dead"],
	feedTypes: ["full", "empty", "starving", "dead"],
	ages: ["child", "young", "adult", "old", "dead"],
	healthTypes: ["healthy", "normal", "ill", "dead"]
}

var cat = new Pet("cat", configs.moods[0], configs.feedTypes[0], configs.ages[0], configs.healthTypes[0]);

cat.setMood();

cat.life();
            
          
!
999px
Loading ..................

Console