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

              
                <div id="koala"></div>
              
            
!

CSS

              
                body{
  background: #25A9FC;
}

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

.head{
  position: absolute;
  top:16.5%;
  left: 25%;
  width: 50%;
  height: 67%;
  background: #A6BECF;
  border-radius: 50%;
  z-index: 3;
}

.outer-ear-left{
  position: absolute;
  width: 33%;
  height: 47%;
  left: 17%;
  top: 20%;
  background: #A6BECF;
  border-radius: 50%;
  z-index: 1;
}

.outer-ear-right{
  position: absolute;
  width: 33%;
  height: 47%;
  right: 17%;
  top: 20%;
  background: #A6BECF;
  border-radius: 50%;
  z-index: 1;
}

.inner-ear-left{
  position: absolute;
  border-radius: 50%;
  width: 28%;
  height: 40%;
  top: 23.5%;
  left: 19.5%;
  background: #819CAF;
  z-index: 2;
}

.inner-ear-right{
  position: absolute;
  border-radius: 50%;
  width: 28%;
  height: 40%;
  top: 23.5%;
  right: 19.5%;
  background: #819CAF;
  z-index: 2;
}

.outer-eye-left{
  position: absolute;
  background: white;
  width: 16%;
  height: 22%;
  top: 32%;
  left: 35%;
  border-radius: 50%;
  z-index: 4;
}

.outer-eye-right{
  position: absolute;
  background: white;
  width: 16%;
  height: 22%;
  top: 32%;
  right: 35%;
  border-radius: 50%;
  z-index: 4;
}

.pupil-left{
  position: absolute;
  width: 4.5%;
  height: 7%;
  top: 40%;
  left: 40.5%;
  border-radius: 50%;
  background: #27354A;
  z-index: 5;
} 

.pupil-right{
  position: absolute;
  width: 4.5%;
  height: 7%;
  top: 40%;
  right: 40.5%;
  border-radius: 50%;
  background: #27354A;
  z-index: 5;
}

.nose{
  position: absolute;
  background: #BE845F;
  width: 13%;
  height: 30.5%;
  left: 43.5%;
  top: 45%;
  border-radius: 50px;
  z-index: 5;
}

.hair-left{
  position: absolute;
  top: 12%;
  left: 39%;
  width: 10%;
	height: 12%;
	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: 14%;
  left: 50%;
  width: 10%;
	height: 12%;
	background:  #A6BECF;
	-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

@media all and (max-width: 600px) {
  .box{
    position: relative;
    margin: auto;
    display: block;
    margin-top: 2%;
    width: 400px;
    height: 280px;
    background: none;

  }
}
              
            
!

JS

              
                //village
class Koala extends React.Component {
  render() {
    return (
      <Box colors={this.props.colors}/>
    )
  }
}

//neighborhood
class Box extends React.Component {
  render() {
    return (
     <div className="box">
       <EarLeft colors={this.props.colors}/>
       <EarRight colors={this.props.colors}/>
       <EyeLeft colors={this.props.colors}/>
       <EyeRight colors={this.props.colors}/>
       <Head colors={this.props.colors}/>
       <Nose color={this.props.colors.brown}/>
       <HairLeft color={this.props.colors.lightGray}/>
       <HairRight color={this.props.colors.lightGray}/>
     </div>
    )
  }
}

//blocks
class EarLeft extends React.Component {
  render() {
    return (
      <div>
        <OuterEarLeft color={this.props.colors.lightGray}/>
        <InnerEarLeft color={this.props.colors.darkGray}/>
      </div>
    )
  }
}

class EarRight extends React.Component {
  render() {
    return (
      <div>
        <OuterEarRight color={this.props.colors.lightGray}/>
        <InnerEarRight color={this.props.colors.darkGray}/>
      </div>
    )
  }
}

class EyeLeft extends React.Component {
  render() {
    return (
      <div>
        <OuterEyeLeft color={this.props.colors.white}/>
        <PupilLeft color={this.props.colors.navy}/>
      </div>
    )
  }
}
class EyeRight extends React.Component {
  render() {
    return (
      <div>
        <OuterEyeRight color={this.props.colors.white}/>
        <PupilRight color={this.props.colors.navy}/>
      </div>
    )
  }
}

//houses
class Head extends React.Component {
  state = {color: this.props.colors.lightGray};

  componentDidMount() {
    setTimeout( () => {
      this.setState({color: this.props.colors.darkGray});
    }, 1000)
  }

  componentWillMount() {
    this.setState({color: this.props.colors.white});
  }

  updateColor() {
    this.setState({color: this.props.colors.darkGray});
  }

  render() {
    return (
      <div onClick={this.updateColor.bind(this)} style={{background: this.state.color}} className="head"></div>
    )
  }
}

class Nose extends React.Component {
  render() {
    return (
      <div style={{background: this.props.color}} className="nose"></div>
    )
  }
}

class HairLeft extends React.Component {
  render() {
    return (
      <div style={{background: this.props.color}} className="hair-left"></div>
    )
  }
}

class HairRight extends React.Component {
  render() {
    return (
      <div style={{background: this.props.color}} className="hair-right"></div>
    )
  }
}

class OuterEarRight extends React.Component {
  render() {
    return (
      <div style={{background: this.props.color}} className="outer-ear-right"></div>
    )
  }
}

class InnerEarRight extends React.Component {
  render() {
    return (
      <div style={{background: this.props.color}} className="inner-ear-right"></div>
    )
  }
}

class OuterEarLeft extends React.Component {
  render() {
    return (
      <div style={{background: this.props.color}} className="outer-ear-left"></div>
    )
  }
}

class InnerEarLeft extends React.Component {
  render() {
    return (
      <div style={{background: this.props.color}} className="inner-ear-left"></div>
    )
  }
}

class OuterEyeLeft extends React.Component {
  render() {
    return (
      <div style={{background: this.props.color}} className="outer-eye-left"></div>
    )
  }
}

class PupilLeft extends React.Component {
  render() {
    return (
      <div style={{background: this.props.color}} className="pupil-left"></div>
    )
  }
}

class OuterEyeRight extends React.Component {
  render() {
    return (
      <div style={{background: this.props.color}} className="outer-eye-right"></div>
    )
  }
}

class PupilRight extends React.Component {
  render() {
    return (
      <div  style={{background: this.props.color}} className="pupil-right"></div>
    )
  }
}

//props objects
const colorsObject = {white: "#FFFFFF", lightGray: "#A6BECF", darkGray: "#819CAF", brown: "#BE845F", navy: "#27354A"}

//"inject" to DOM
ReactDOM.render(
  <Koala colors={colorsObject}/>,
  document.getElementById('koala')
);
              
            
!
999px

Console