cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <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>

            
          
!
            
              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%);
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console