cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation


Save Automatically?

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.

              <div class="main">
  <div class="sub default">sub1</div>
  <div class="sub default" id="ref">sub2</div>
  <div class="sub default">sub3</div>
              .sub {
  height: 50px;
  width: 100px;
  color: white;
  text-align: center;
  line-height: 50px;

.default {
  background-color: rgba(255, 0, 0, 0.8);
  border-bottom: 2px solid rgb(222, 0, 0);

.add {
  background-color: rgba(0, 0, 255, 0.8);
              const addDiv = () => {
// 親要素
const main = document.querySelector(".main");

// 追加要素の作成
const sub4 = document.createElement("div");
sub4.classList.add("sub", "add");

// 追加するときの起点となる要素
const ref = document.querySelector("#ref");

main.insertBefore(sub4, ref);

Loading ..................