Chapter 3: Building Douglas

From Chapter 3 of Writing Computer Code by Chris Minnick and Eva Holland.

by Daniel Hall

HTML

<div id="robot">
   <div id="head">
   <div class ="eye" id="righteye"></div>
   <div class ="eye" id="lefteye"></div>  
   <div id="nose"></div>
   <div id="mouth"></div>
</div>   
<div class="arm" id="rightarm"></div>
<div class="arm" id="leftarm"></div>
<div id="body"><p id="message">I LOVE TO CODE!</p>
</div>

CSS

body {
    font-family: Arial;
}
p {
    font-size: 1em;
}
.eye {
    background-color:purple;
    width:20%;
    height:20%;
    border-radius: 5%;
}
.arm {
    background-color: rgb(000,000,0);
    position: absolute;
    top: 35%;
    width: 5%;
    height: 40%;
}

#head {
    width:30%;
    height:30%;
    border-radius: 10%;
    background-color: rgb(000,000,0);
    position: absolute;
    left: 33%;
    top: 5%;
}
#righteye {
    position: absolute;
    left: 20%;
    top: 20%;
}
#lefteye {
    position: absolute;
    left: 60%;
    top: 20%;
}
#nose {
    position: absolute;
    left: 45%;
    top: 50%;
    width: 15%;
    height: 10%;
    background-color: yellow;
}
#mouth {
    position: absolute;
    width: 65%;
    height: 20%;
    left: 20%;
    top: 70%;
    background-color: green;
}
#body {
    position: absolute;
    left: 25%;
    top: 35%;
    width: 45%;
    height: 55%;
    background-color:  rgb(110,000,999);
    text-align:center;
    padding-top: 30px;
}

#rightarm {
    position:absolute;
    left:20%;
}
#leftarm {
    position: absolute;
    left: 70%;
}

JavaScript

document.getElementById("lefteye")
     .style.backgroundColor = "blue";
document.getElementById("head")
    .style.transform = "rotate(15deg)";