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

              
                <header>
  <div class="div1">
    div1
  </div>
  <div class="div2">
    div2
  </div>
  <div class="div3">
    div3
  </div>
  <div class="div4">
    div4
  </div>
  <div class="div5">
    div5
  </div>
</header>
              
            
!

CSS

              
                /* 使用している画像のサイズは1200x600 */
header {
  width: 1200px;
}

div {
  border: solid;
  margin: 10px;
}

/* OKパターン */
.div1 {
  widht: 100%;
  background-image: url(https://source.unsplash.com/random/1200x600);
  background-size: cover;
  /* (画像の横幅 / 画像の縦幅) * 100 */
  padding-top: 50%;  
}

/* background-imageのみ指定 */
/*  →要素の高さが0なので背景画像は表示されない */
.div2 {   
  widht: 100%;
  background-image: url(https://source.unsplash.com/random/1200x600);  
}

/* 要素に「div3」というテキストが入っている */
/*  →テキスト高さ分だけ背景画像が表示される */
.div3 {
  widht: 100%;
  background-image: url(https://source.unsplash.com/random/1200x600);    
}

/* 要素の高さを指定 */
/*  →要素の高さ分だけ背景画像が表示される */
.div4 {
  widht: 100%;
  height: 200px;
  background-image: url(https://source.unsplash.com/random/1200x600);    
}

/* padding-topに「(画像の横幅 / 画像の縦幅) * 100」の値を%で指定 */
/*  →比率を保ったままブラウザの大きさに合わせて背景画像が表示される */
/*   しかし、background-sizeにcoverを指定していないため、back5というテキストの高さ分、背景画像が繰り返し表示される */
.div5 {
  widht: 100%;
  background-image: url(https://source.unsplash.com/random/1200x600);
  /* (画像の横幅 / 画像の縦幅) * 100 */
  padding-top: 50%;
}


              
            
!

JS

              
                
              
            
!
999px

Console