How To Create Robot Using CSS Code With Android
Having been a keen graphic designer for many years, I've always wanted to know what I could design using CSS.
After searching the internet for possible graphics to create using CSS3, one of the first graphics I saw was the Android ‘Droid’. In this tutorial, we'll create a ‘Droid’ robot using HTML and CSS.
First, we create the basic structure of our Droid. For this, we use basic HTML div tags. We break up our Droid into sections and assign a div to each. This provides the basic body and structure of the Droid (for example, head, upper body and lower body):
<div id="android"> <div id="antenna"> <div id="left_antenna"> </div> <div id="right_antenna"> </div> </div> <div id="head"> <div id="left_eye"> </div> <div id="right_eye"> </div> </div> <div id="upper_body"> <div id="left_arm"> </div> <div id="torso"> </div> <div id="right_arm"> </div> </div> <div id="lower_body"> <div id="left_leg"> </div> <div id="right_leg"> </div> </div> </div>The code below gives all the body parts of Droid their green colour.
#left_antenna, #right_antenna, #head, #left_arm, #torso, #right_arm, #left_leg, #right_leg { background-color: #a4c739; }<!-- <div id="left_antenna"> </div> <div id="right_antenna"> </div> -->It's important to note that any of the figures I’ve used can be changed. However, if you change any of the measurements, use a bit of trial and error to ensure it looks correct.
#head { width: 400px; margin: 0 auto; height: 200px; border-radius: 200px 200px 0 0; -webkit-border-radius: 200px 200px 0 0; -moz-border-radius: 200px 200px 0 0; -ms-border-radius: 200px 200px 0 0; -o-border-radius: 200px 200px 0 0; margin-bottom: 10px; } #upper_body { width: 700px; height: 400px; margin: 0 auto; text-align: center; } #left_arm, #right_arm { width: 100px; height: 325px; float: left; border-radius: 100px; -webkit-border-radius: 100px; -moz-border-radius: 100px; -ms-border-radius: 100px; -o-border-radius: 100px; } #left_arm { margin-right: 10px; margin-left: -10px; } #torso { width: 400px; height: 400px; float: left; border-radius: 0 0 50px 50px; -webkit-border-radius: 0 0 50px 50px; -moz-border-radius: 0 0 50px 50px; -ms-border-radius: 0 0 50px 50px; -o-border-radius: 0 0 50px 50px; margin-right: 10px; } #lower_body { width: 400px; height: 200px; margin: 0 auto; } #left_leg, #right_leg { width: 100px; height: 200px; float: left; border-radius: 0 0 100px 100px; -webkit-border-radius: 0 0 100px 100px; -moz-border-radius: 0 0 100px 100px; -ms-border-radius: 0 0 100px 100px; -o-border-radius: 0 0 100px 100px; } #left_leg { margin-left: 75px; } #right_leg { margin-left: 50px; }This is a clear picture of created robot
For the final part of this tutorial we're going to add the antenna and eyes. We start by removing the comments around the antenna and eye divs. The eyes use the same border-radius properties that we’ve used to create the body of Droid. We're also going to use the CSS position property to position them correctly.
#left_eye, #right_eye { width: 30px; height: 30px; border-radius: 15px; -webkit-border-radius: 15px; -moz-border-radius: 15px; -ms-border-radius: 15px; -o-border-radius: 15px; background-color: white; float: left; } #left_eye { position: relative; top: 100px; left: 90px; } #right_eye { position: relative; top: 100px; left: 250px; }#antenna { width: 400px; height: 100px; margin: 0 auto; } #left_antenna, #right_antenna { width: 10px; height: 100px; border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; -o-border-radius: 10px; float: left; } #left_antenna { position: relative; top: 40px; left: 70px; transform:rotate(-33deg); -webkit-transform: rotate(-33deg); -moz-transform: rotate(-33deg); -ms-transform: rotate(-33deg); -o-transform: rotate(-33deg); } #right_antenna { position: relative; top: 40px; left: 310px; transform: rotate(33deg); -webkit-transform: rotate(33deg); -moz-transform: rotate(33deg); -ms-transform: rotate(33deg); -o-transform: rotate(33deg); }
 
0 Comments