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="wrapper">
  <h1></h1>
  <h2>text-align:center;</h2>
  <div class="demo-01">
    <div class="outer">
      <div class="inner">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit,<br>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      </div>
    </div>
  </div>
  <h2>margin:0 auto;</h2>
  <div class="demo-02">
    <div class="outer">
      <div class="inner">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit,<br>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      </div>
    </div>
  </div>
  <h2>display:inline-block;</h2>
  <div class="demo-03">
    <div class="outer">
      <div class="inner">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit,<br>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      </div>
    </div>
  </div>
  <h2>vertical-align:middle;</h2>
  <div class="demo-04">
    <div class="outer">
      <div class="inner">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit,<br>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      </div>
    </div>
  </div>
  <div class="demo-04 sample">
    <h3>【使用例】</h3>
    <div class="table">
      <div class="cells point">
        <p>POINT</p>
      </div>
      <div class="cells">
        <p class="title">vertical-align: middle;</p>
        <p>内容量よりも高さのあるブロックにおいて、中身を上下中央寄せにしたいときはvertical-alignの出番です。</p>
      </div>
    </div>
  </div>
  <h2>position:absolute; + margin: auto;</h2>
  <div class="demo-05">
    <div class="outer">
      <div class="inner">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit,<br>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      </div>
    </div>
  </div>
  <h2>transform</h2>
  <div class="demo-06">
    <div class="outer">
      <div class="inner">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit,<br>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      </div>
    </div>
  </div>
  <div class="demo-06 sample">
    <h3>【ネガティブマージンの使用例】</h3>
    <a href="#" class="btn">
      ボタン<i class="c-ico-arrow-right"></i>
    </a>
    <a href="#" class="btn">
      文字量が<br>多めのボタン<i class="c-ico-arrow-right"></i>
    </a>
    <a href="#" class="btn">
      文字量が<br>とてもとても<br>多めのボタン<i class="c-ico-arrow-right"></i>
    </a>
  </div>
  <h2>display:flex;</h2>
  <div class="demo-07">
    <div class="outer">
      <div class="inner">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit,<br>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                /* base
----------------------------------------------------*/
*{
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
html {
  font-size: 87.5%;
  font-family: "Roboto","ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", Osaka, "メイリオ", Meiryo, "MS Pゴシック", "MS PGothic", sans-serif;
  line-height: 1.6;
  letter-spacing: .05em;
}
body {
  font-size: 14px;
  font-size: 1rem;
}
h2{
  font-weight:normal;
}
h3{
  font-weight:normal;
  margin-top: 0;
}
.wrapper{
  width: 80%;
  margin: 0 auto;
  max-width: 712px;
  min-width: 350px;
}
div[class^=demo]{
  margin-bottom: 5rem;
}
.sample{
  border-left: 3px solid #ddd;
  padding: 10px 0 10px 20px;
  margin-left: 10px;
}
/* common
----------------------------------------------------*/
.outer{
padding: 10px;
background: #e6ecf2;
}
.demo-04 .outer,
.demo-05 .outer,
.demo-06 .outer,
.demo-07 .outer{
    height: 10rem;
    text-align: center;
}
.inner{
background: rgba(255,255,255,0.3);
border: 1px solid #fff;
}

/* 【1】text-align: center;
----------------------------------------------------*/
.demo-01 .inner{
  text-align: center;
}
/* 【2】margin: 0 auto;
----------------------------------------------------*/
.demo-02 .inner{
  width: 80%;
  margin: 0 auto;
  max-width: 500px;
}
/* 【3】display: inline-block;
----------------------------------------------------*/
.demo-03 .outer{
  text-align: center;
}
.demo-03 .inner{
  display: inline-block;
  text-align: left;
}
/* 【4】vertical-align: middle;
----------------------------------------------------*/
.demo-04 .outer{
  display: table;
  width: 100%;
}
.demo-04 .inner{
  display: table-cell;
  vertical-align: middle;
}
/*使用例*/
.demo-04 .table{
  color: #706f6f;
  display: table;
  width:60%;
  border: 1px solid #d5d5d5;
}
.demo-04 .cells{
  display: table-cell;
  padding:.5rem 1rem;
}
.demo-04 .point{
   background: #f58f85;
  color: #fff;
  width:30%;
  text-align:center;
  vertical-align:middle;
  font-weight: bold;
}
.demo-04 .title{
  color :#b40000;
  font-weight: bold;
}
/* 【5】position: absolute; + margin: auto;
----------------------------------------------------*/
.demo-05 .outer{
  position: relative;
}
.demo-05 .inner{
  width: 80%;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3.2rem;
  margin: auto;
}
/* 【6】transform
----------------------------------------------------*/
.demo-06 .outer{
  position: relative;
}
.demo-06 .inner{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translateY(-50%) translateX(-50%);
  -webkit- transform: translateY(-50%) translateX(-50%);
}
/*ネガティブマージンの使用例*/
.demo-06 .btn{
  background: #2e6fcf;
  text-decoration: none;
  text-align: left;
  color:#fff;
  width: 30%;
  margin-right:2%;
  padding: .5em 1.5em .5em 2em;
  position: relative;
  display: inline-block;
  vertical-align: middle;
}
.demo-06 .btn i{
    margin-top: -.5em;
    position: absolute;
    right: 1em;
    top: 50%;
    line-height: 1;
}
.demo-06 .btn i:before{
  content:">";
  font-style: normal;
  font-weight: bold;
}

/* 【7】display: flex;
----------------------------------------------------*/
.demo-07 .outer{
	display: flex;
	justify-content: center;
	align-items: center;
}



              
            
!

JS

              
                
              
            
!
999px

Console