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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <header>  
 <h1>Vertical Centering: Everything You Need to Know</h1>
    <a href="http://webdesignerwall.com/tutorials/css-vertical-centering-everything-need-know" target="_blank">View Tutorial</a>
</header>

<div class="intro">*Hover over the text to see how each method centers it within its parent.</div>

<div class="container">
  <h2>absolute</h2>
  <div class="item one"><p>To be able under all circumstances to practice five things constitutes perfect virtue; these five things are gravity, generosity of soul, sincerity, earnestness and kindness.</p></div>
</div>
<div class="container">
  <h2>table</h2>
  <div class="item two"><p>To be able under all circumstances to practice five things constitutes perfect virtue; these five things are gravity, generosity of soul, sincerity, earnestness and kindness.</p></div>
</div>
<div class="container">
  <h2>transform</h2>
  <div class="item three"><p>To be able under all circumstances to practice five things constitutes perfect virtue; these five things are gravity, generosity of soul, sincerity, earnestness and kindness.</p></div>
</div>
<div class="container">
  <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
 <h2>line height</h2>
  <div class="item four"><i class="fa fa-css3" aria-hidden="true"></i></div>
</div>
<div class="container">
  <h2>padding</h2>
  <div class="item five"><p>When I walk along with two others, from at least one I will be able to learn.</p></div>
</div>
<div class="container">
  <h2>flexbox</h2>
  <div class="item six"><p>To be able under all circumstances to practice six things constitutes perfect virtue; these six things are gravity, generosity of soul, sincerity, earnestness, kindness and vertical alignment.</p><a href="#"> Link </a></div>
</div>
<div class="container">
  <h2>Combined Elements</h2>
  <div class="item with-image">
    <figure><img src="https://24.media.tumblr.com/1d8dd5361a12d9c51077764adf9a1158/tumblr_mvdci7SSY51r4mh0bo1_r1_500.gif"></figure>
    <div class="content"><h3>Maybe A Title</h3><p>When I walk along with two others, from at least one I will be able to learn.</p></div>
  </div> 
</div>

              
            
!

CSS

              
                html {
  box-sizing: border-box;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  background: linear-gradient(90deg, #f598a8, #f6edb2);
  align-items: center;
  height: 100vh;
  position: relative;
  font-family: 'source sans pro', sans-serif;
}
.intro{
  font-size: 1.2rem;
  display: block;
  text-align: center;
  color: #555;
  font-style: italic;
}
.container {
  width: 80vw;
  margin: 2vw auto;
  border: 0.25rem solid rgba(255, 255, 255, 0.1);
  padding: 2vw;
  transition: border 0.25s ease;
}
.container h2{
    padding: 0 0 0 1rem;
    opacity: 0.25;
    font-size: 2rem;
    transition: opacity 0.25s ease;
 }
.item {
  position: relative;
  background-color: white;
  margin: 1rem;
  padding: 1rem;
  min-height: 33vh;
  overflow: hidden;
  font-size: 1.25rem;
  color: rgba(0, 0, 0, 0.25);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
  transition: all 0.25s ease;
}
.item:hover {
    color: rgba(0, 0, 0, 0.75);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
}
.item p{
  margin: 0;
  padding: 0;
  border: 0.25rem dashed rgba(239, 230, 195, 0.1);
}
.item:hover p {
   border: 0.25rem dashed rgba(239, 230, 195, 0.75);
}
.item:hover p:after {
    opacity: 0.5;
}
/* Positioning */

/* Absolute */

.one p{
    position:absolute;
    top: 33%;
    right:0;
    bottom:0;
    left:0;
    margin: auto;
    padding: 0 2rem;
}
/* table */
.two{
  display: table;
}
.two p{
  display: table-cell;
  vertical-align: middle;
}
/* translate */
.three{
  height: 33vh;
}
.three p{
    position: relative;
    top: 50%;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
}
/* line height */
.four{
  width: 4rem;
  height: 4rem;
  border-radius: 100%;
  margin: 0 auto;
  padding: 0;
  min-height: auto;
  line-height: 4rem;
  text-align: center;
}


/* padding */
.five{
  padding: 16.5vh 8.25vh;
  text-align: center;
}


/* flexbox */
.six{
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* flexbox with image */
.with-image{
  height: auto;
  display: flex;
  flex-direction: row;
}
.with-image img, .with-image .content{
  width: calc(50%);
}
.with-image figure img{
  width: 100%;
  height: auto;
  object-fit: contain;
}
.content{
  margin: 0 2rem;
  align-self: center;
}


/* General style */
a{
    font-size: .8rem;
    text-decoration: none;
    color: #999;
    text-transform: uppercase;
    font-family: sans-serif;
}

header{
  width: 100%;
  display: block;
  background: #FFF;
  height: 40px;
  margin-bottom: 4%;
  color: #ccc;
  font-family: sans-serif;
  font-weight: bold;
  box-shadow: 0px 2px 0px 0px rgba(125,121,125,0.3);
  overflow: hidden;
}
header h1, header a{
  display: inline-block;
  font-size: .8rem;
  margin: auto 10px;
  line-height: 40px;

}
header h1{
    text-transform: uppercase;
    letter-spacing: 1px;
}
header a{
  text-decoration: none;
  background-color: #eee;
  color: #999;
  padding: 0 20px;
  transition: all ease-in-out .3s;
}
header a:hover{
  background-color: #93dfec;
  color: #eee;
  margin-left: -3px;
}



@media screen and (max-width: 667px){
  .item:not(.four){
    min-height: 50vh;
  }
  .item span{
    font-size: 4vw;
  }
  .with-image{
    flex-direction: column;
    justify-content: center;
  }
 .with-image img, .with-image .content{
  text-align: center;
  width: calc(100%);
  height: calc(100%);
}
              
            
!

JS

              
                
              
            
!
999px

Console