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 class="container">
      <div class="item">
        <img src="https://user-images.githubusercontent.com/3121046/89357326-1c68ff80-d6fb-11ea-8dcb-bd66af450c50.jpg" alt="" />
        <p>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        </p>
      </div>
      <div class="item">
        <img src="https://user-images.githubusercontent.com/3121046/89357326-1c68ff80-d6fb-11ea-8dcb-bd66af450c50.jpg" alt="" />
        <p>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        </p>
      </div>
      <div class="item">
        <img src="https://user-images.githubusercontent.com/3121046/89357326-1c68ff80-d6fb-11ea-8dcb-bd66af450c50.jpg" alt="" />
        <p>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        </p>
      </div>
    </div>
              
            
!

CSS

              
                /*
- 600px以上はflexboxで横並び
- 600px未満はflex-directionをcolumnにして縦並び
-------------------------------------------------- */
.container {
  display: flex;
  justify-content: space-between;
  background-color: blue;
  width: 640px; /* アイテム 200px x 3(個数)+ アイテムの間隔 20px x 2 */
  margin: 0 auto; /* 親要素の中央よせ */
}

.item {
  background: #edf;
  width: 200px;
}

img {
  width: 100%;
}

p {
  text-align: left;
  padding: 10px;
  margin-top: 5px;
  overflow-wrap: break-word; /* 文字がはみださないように折り返しをする */
}

@media screen and (max-width: 599px) {
  /* 600px未満の場合に適用される */
	.container {
    flex-direction: column; /* flexの向きを垂直方向に変更。主軸・交差軸が入れ替わる */
    align-items: center; /* 交差軸を中心揃えにする(= 中央寄せになる) */
    width: 100%; /* 画面の幅に応じて親要素の幅が動的になるようにする */
	}
  .item {
    width: 60%; /* 親要素に対して60%の幅でカードを表示 */
    margin-bottom: 10px; /* 縦並びのアイテムにマージンを用意 */
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console