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

              
                <p>
  青背景の子要素が、赤背景の親要素の上から50%・左から50%に配置されています。これがpositionを使った配置です。
</p>
<div class="position">
  <div class="parent">
    <div class="child"></div>
  </div>
</div>
<p>要素が横に並べられていきます。これがflexを用いた配置です。</p>
<div class="flex">
  <div></div>
  <div></div>
  <div></div>
</div>
<p>
  要素を自由に配置し、間に空白を設けたり、要素を伸ばしたりもできます。これがグリッドレイアウトです。
</p>
<div class="grid">
  <div class="first"></div>
  <div class="second"></div>
  <div class="third"></div>
</div>

              
            
!

CSS

              
                .normal div {
  width: 100px;
  height: 100px;
  background-color: grey;
  margin-bottom: 5px;
}

.position {
  margin-bottom: 50px;
}
.position .parent {
  width: 100px;
  height: 100px;
  background-color: red;
  position: relative;
}
.position .parent .child {
  position: absolute;
  width: 80px;
  height: 80px;
  background-color: blue;
  -webkit-animation: slideposition 2s linear forwards;
          animation: slideposition 2s linear forwards;
}

@-webkit-keyframes slideposition {
  from {
    top: 0%;
    left: 0%;
  }
  to {
    top: 50%;
    left: 50%;
  }
}

@keyframes slideposition {
  from {
    top: 0%;
    left: 0%;
  }
  to {
    top: 50%;
    left: 50%;
  }
}
.flex {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 5px;
}
.flex div {
  width: 100px;
  height: 100px;
  background-color: grey;
  margin-bottom: 5px;
}

.grid {
  width: 300px;
  height: 300px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5px;
  -webkit-transition: 2s;
  transition: 2s;
}
.grid div {
  background-color: grey;
}
.grid .first {
  grid-column: 1/2;
  grid-row: 1/2;
  -webkit-animation: grid-anim-1 2s linear infinite;
          animation: grid-anim-1 2s linear infinite;
}
.grid .second {
  grid-column: 2/3;
  grid-row: 1/3;
  background-color: green;
}
.grid .third {
  grid-column: 2/4;
  grid-row: 3/4;
  background-color: aqua;
}

@-webkit-keyframes grid-anim-1 {
  from {
    grid-row: 1/2;
  }
  to {
    grid-row: 1/4;
  }
}

@keyframes grid-anim-1 {
  from {
    grid-row: 1/2;
  }
  to {
    grid-row: 1/4;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console