Pen Settings

HTML

CSS

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.

+ 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

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.

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

              
                  <h1>Centering with CSS(Vertical & Horizontal)</h1>

  <h3>Vertical Align - inline/inline-block 요소</h3>

  <div class="wrapper">
    <p>padding-top과 padding-bottom 속성값을 동일하게 적용</p>
    <div class="center inline">
      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </div>
    <p>height와 line-height 속성값을 동일하게 적용</p>
    <div class="center line-height">
      <a href="#">Home</a>
      <a href="#">Blog</a>
      <a href="#">Contact</a>
    </div>
    <p>vertical-align 속성과 table을 적용</p>
    <div class="center vertical-align">
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <p>Flexbox</p>
    <div class="center flex">
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
  </div>
  </div>

  <h3>Vertical Align - block 요소</h3>

  <div class="wrapper-block">
    <p>요소의 높이가 고정되어 있는 경우</p>
    <div class="center block">
      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </div>
  </div>

  <div class="wrapper-block">
    <p>요소의 높이가 불확정 상태의 경우</p>
    <div class="center block-unknown-height">
      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </div>
  </div>

  <div class="wrapper-block-flex">
    <p>Flexbox</p>
    <div class="center flex">
      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </div>
  </div>
              
            
!

CSS

              
                    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    html, body {
      width: 100%;
      height: 100%;
    }
    body {
      background: url(https://subtlepatterns.com/patterns/white_texture.png);
      font: 100 14px sans-serif;
      color: #444555;
      background-color: #ddd;
    }

    h1 {
      font-weight: 100;
      font-size: 2.7em;
      text-align: center;
      margin: 20px;
    }

    h3 {
      font-weight: 100;
      font-size: 1.8em;
      text-align: center;
      margin: 20px;
    }

    a {
      text-decoration: none;
      color: white;
      padding-right: 50px;
    }

    .wrapper {
      max-width: 700px;
      height: 600px;
      margin: 10px auto;
      padding: 10px;
      background-color: #fff;
      /*This prevents the margins to collapse.*/
      overflow:hidden;
    }

    .center {
      margin: 10px;
      padding: 0 30px;
      background: #333;
      border-radius: 5px;
      color: white;
    }

    .center.inline {
      padding: 30px;
    }

    .center.line-height {
      height: 100px;
      line-height: 100px;
    }

    .center.vertical-align {
      display: table;
      height: 100px;
    }

    .center.vertical-align p {
      display: table-cell;
      vertical-align: middle;
    }

    .center.flex {
      display: flex;
      /*위에서 아래로 수직 배치*/
      flex-direction: column;
      /*중앙정렬*/
      justify-content: center;
      height: 100px;
    }

    /*-------------------------------------*/
    .wrapper-block {
      max-width: 700px;
      height: 200px;
      margin: 10px auto;
      padding: 10px;
      background-color: #fff;
      /*This prevents the margins to collapse.*/
      /*overflow:hidden;*/
      position: relative;
    }

    .center.block {
      /*요소의 높이가 고정되어 있는 경우*/
      height: 100px;
      padding: 30px;
      position: absolute;
      top: 50%;
      /*요소의 높이(100px)의 반 만큼 위로 이동*/
      margin-top: -50px;
    }

    .center.block-unknown-height {
      padding: 30px;
      position: absolute;
      top: 50%;
      /*요소의 높이의 반 만큼 위로 이동*/
      transform: translateY(-50%);
    }

    .wrapper-block-flex {
      max-width: 700px;
      height: 200px;
      margin: 10px auto;
      padding: 10px;
      background-color: #fff;
      display: flex;
      flex-direction: column;
      justify-content: center;
    }

    .wrapper-block-flex .center.flex {
      padding: 30px;
    }
              
            
!

JS

              
                
              
            
!
999px

Console