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="app"></div>
              
            
!

CSS

              
                body {
  padding: 2vw;
  display: flex;
  justify-content: center;
  align-items: center;
}
.house {
  border: 2px solid #90f;
  padding: 5px;
  display: flex;
}
.room {
  border: 1px solid red;
  padding: 5px;
  margin: 5px;
}
.bathroom {
  border: 1px solid green;
  padding: 5px;
  margin: 5px;
}
.man {
  border: 1px solid lime;
  padding: 5px;
  margin-bottom: 5px;
}
.dog {
  padding: 5px;
  border: 1px solid orange;
  margin-bottom: 5px;
}
              
            
!

JS

              
                // 一个房子里面有一个房间和一个洗手间,房间里面有一个人和两条狗
// 请你完成组件:House,Room,Bathroom,Man,Dog,
// 它们的最外层都用 div 标签包裹起来,类名分别为:house,room,bathroom,man,dog
// 组件的实现应该具有上述的嵌套关系

// 创建House组件, House组件包括Room、Bathroom两个组件
class House extends React.Component {
  render() {
    return (
      <div className='house'>
        <Room />
        <Bathroom />
      </div>
    )
  }
}

// 创建Room组件,房间里有一个人和两只狗
class Room extends React.Component {
  render() {
    return (
      <div className='room'>
        <Man />
        <Dog />
        <Dog />
      </div>
    )
  }
}

// 创建Bathroom组件
class Bathroom extends React.Component {
  render() {
    return (
      <div className='bathroom'>
        <h1>This is bathroom</h1>
      </div>
    )
  }
}

// 创建Man组件
class Man extends React.Component {
  render () {
    return (
      <div className='man'>
        <h1>This is Man</h1>
      </div>
    )
  }
}

// 创建Dog组件
class Dog extends React.Component {
  render () {
    return (
      <div className='dog'>
        <h1>This is dog</h1>
      </div>
    )
  }
}

ReactDOM.render(
  <House />,
  document.getElementById('app')
)
              
            
!
999px

Console