Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                <!-- Learning Pure CSS Art by making "Koala" by following mikemang's tutorial -->
<body>
  <!-- Begin Image --> 
  <!-- Invisible Box--> 
  <div class="box"> <!-- No closing div tag until near the end --> 
    
    <!--Circular Head--> 
    <div class="head"> 
    <!-- Nested divs: 
    All other shapes will be on top of the   
    head-->   
      <!-- Circular Head Copy --> 
      <!-- used to allow the ears to appear  
      behind the head --> 
      <div class="head-copy"></div>
      
      <!--Left Ear ~ Light Gray -->
      <div class="ear-left">
      <!-- Inner ear ~ Dark Gray --> 
        <div class="inner-ear"></div> <!-- Closing div tag of Left ear --> 
      </div>
      <!-- Nested divs: 
      Ear-right is the parent div; inner-ear is a       child div; percentage for widths and    
      heights of shapes applies to parent div -->
      
      <!-- Right Ear ~ Light Gray -->
      <div class="ear-right">
      <!-- Inner Ear ~ Dark Dray --> 
        <div class="inner-ear"></div>
      </div>
      
      <!-- Left Outer Eye ~ White -->
      <div class="eye-left">
          <!-- Pupil ~ Black -->
          <div class="pupil"></div>
      </div>   
      
      <!-- Right Outer Eye ~ White -->
      <div class="eye-right">
          <!-- Pupil ~ Black -->
          <div class="pupil"></div>
      </div>   
      
      <!-- Nose ~ Brown --> 
      <div class="nose"> 
      </div> 
      
      <!-- Challenge: Add Mouth ~ Coral --> 
      <div class="mouth"></div> 
      
        <!--Challenge: Add Tongue ~ Red --> 
        <div class="tongue"></div> 
      
      <!-- Hair ~ Light Gray --> 
      <div class="hair-left"></div> 
      <div class="hair-right"></div>
      
      <!-- End Head --> 
    </div> 
  <!-- End Invisibile Box --> 
  </div> 
  
</body> 

<!-- Check understanding of: 
<div>, position property, top, percentage -->
<!-- 

<div> element: generic container for flow content; doesn't inherently represent anything; used to group element for styling (using class or id attribute), marking a section of a document in a different language (using lang attribute), etc.

flow content: elements in this catebory contain text or embedded content. See MDN for the whole list. 

position property: specifies the type of positioning method used for an element (static, relative, fixed, absolute, sticky); elements are then positioned using the top, bottom, left, and right properites -- set position property first.

position: absolute 
{the element with this property is positioned relative to the nearest positioned ancestor; if element has no positioned ancestors, it uses the document body and moves along with page scrolling} 

--> 
      
              
            
!

CSS

              
                body {
  background: #25A9FC; 
}

.box {
  position: relative; 
  margin: auto;
  display: block; 
  margin-top: 10%;  
  width: 600px; 
  height: 420px; 
  background: none;
  border: solid 4px red;
}

/* position: relative -- the element is positioned relative to its normal position, which is the very top left corner 
$ margin: auto centers the box
$ margin-top: 8% lowers the box by 8%
$ margin: auto was not overwritten 
*/ 

.head {
  position: absolute; 
  top: 16.5%; 
  left: 25%; 
  width: 50%; 
  height: 67%; 
  background: #A6BECF; 
  border-radius: 50%;  
}
/* Position percentages to ABSOLUTELY CENTER: 
left = (100 - width of parent div)/2
top = (100 - height of parent div)/2
*/

.head-copy {
  width: 100%; 
  height: 100%; 
  /* head-copy's parent div is head; it   will be positioned and measured 
  relative to head */
  position: absolute; 
  /* significance of width and height at 100% and before position: absolute? */ 
  background: #A6BECF; 
  border-radius: 50%; 
  z-index: 2; 
}
/* 
$ z-index indicates the depth of the div (think layers) ; the highter the z-index, the closer that div is to the top. Example: 
Have 2 divs. z-index: 1 would be like the bottom layer; z-index: 2 would be the top layer. 
$ ears will the bottom layer and will have z-index: 1
$ giving head div a value of z-index: 2 won't put the ears behind the head - WHY?
$ giving head-copy div a vlue of z-index: 2 will put ears behind the head 
*/ 

.ear-left{
  position: absolute; 
  width: 60%; 
  height: 65%; 
  left: -20%;
  /* negative sign: shift in the specified direction */  
  top: 5%; 
  background: #A6BECF; 
  border-radius: 50%; 
  z-index: 1; 
}

.ear-right{
  position: absolute; 
  width: 60%; 
  height: 65%; 
  right: -20%; 
  top: 5%; 
  background: #A6BECF; 
  border-radius: 50%; 
  z-index: 1; 
}

/* inner-ear's parent div is ear-left and ear-right*/ 
.inner-ear{
  position: absolute; 
  border-radius: 50%; 
  width: 80%; 
  height: 80%; 
  top: 10%; 
  left: 10%; 
  /* top and left are relative to the ears */ 
  background: #819CAF; 
}

/*parent div is head */ 
.eye-left {
  position: absolute; 
  border-radius: 50%; 
  width: 30%; 
  height: 33%; 
  top: 25%; 
  left: 21%; 
  background: white;
  z-index: 3; 
 }

/*parent div is head */ 
.eye-right {
  position: absolute; 
  border-radius: 50%; 
  width: 30%; 
  height: 33%;
  top: 25%; 
  right: 21%; 
  /* original position is at the top left corner of head. And no right property applied does not mean right: 100% (which is not the maximum furthest distance)
  $default right: percentage is at top left corner of parent div */ 
  background: white;
  z-index: 2; 
}

.pupil {
  position: absolute; 
  width: 28%; 
  height: 30%; 
  top: 35%; 
  left: 36%; 
  border-radius: 50%; 
  background: #27354A; 
}

.nose {
  position: absolute; 
  background: #BE845F; 
  width: 25%; 
  height: 40%; 
  left: 37%; 
  top: 45%; 
  border-radius: 50px; /* round the corners of the rectangle - when rounding slightly, easier to use px instead of percentage. */ 
  z-index: 4; /*on top of eyes */ 
}

.mouth{
  position: absolute; 
  background: 	#F08080; 
  width: 40%; 
  height: 22%; 
  left: 30%; 
  top: 70%; 
  z-index: 3; 
  border-radius: 50%; 
}

/*parent div of tongue div is mouth div*/ 
.tongue {
  position: absolute; 
  background: red; 
  border-radius: 50%;
  width: 29%; 
  height: 30%;
  left: 35%; 
  top: 65%;
  z-index: 3; 
  
}

.hair-left {
  position: absolute; 
  top: -8%; /*to stick out above head */ 
  left: 30%;
  width: 20%; 
  height: 20%; 
  background: #A6BECF; 
  -webkit-clip-path: polygon (50% 0%, 0% 100%, 100% 100%); 
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.hair-right{
  position: absolute; 
  top: -4%; /* to stick out above head */ 
  left: 48%;
  width: 20%;
  height: 20%; 
  background: #A6BECF; 
  -webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%); clip-path: polygon(50% 0%, 0% 100%, 100% 100%); 
}

/*clip-path used to make any shape outside a square, rectangle, and circle. This method is supported by Safari, Chrome, and Opera, but not Firefox. 
$ the tool called Clippy automatically gives us the clip-path for different shapes */ 


              
            
!

JS

              
                
              
            
!
999px

Console