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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              
<h1>Vertical aligning multiple lines of text without <code>table-cell</code>.</h1>
<h3 class="subtitle">Examples of this method</h3>
<div class="box-wrapper">
  <div class="container">
    <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
  </div>
  <div class="container">
    <span>Click me</span>
  </div>
  <div class="container">
    <span> Praesent ac nisi velit. Sed tristique viverra nisl et pretium. Aliquam feugiat gravida metus sit amet varius. Suspendisse molestie felis vel massa aliquam, eget euismod erat aliquet. Praesent eu eleifend purus. Aenean tincidunt lobortis magna et suscipit.</span>
  </div>
</div>
<h3 class="subtitle">Code</h3>
<pre class="code-block">
  &lt;div&gt;
      &lt;span&gt;Vertically aligned text&lt;/span&gt;
  &lt;/div&gt;
  
  div{
      min-height:100px;
      line-height:110px;
  }
  div > span{
      display:inline-block;
      line-height:20px;
      vertical-align:middle;
  }
</pre>
<div class="note">
  This method works when you have boxes of fixed height. You can use <code>min-height</code> to set a minimum height to the parent box thus allowing the text to expand if there are more lines.
</div>
            
          
!
            
              body{
  font-family:'Roboto', sans-serif;
  font-size:18px;
  padding:50px;
  color:#fff;
  margin:0;
  background:url(http://www.hdwallsource.com/img/2014/11/purple-gaussian-wallpaper-43132-44162-hd-wallpapers.jpg) #5E8AB5;
}
h2{
  font-size:30px;
  font-weight:normal;
  background:rgba(255,255,255, 0.5);
  padding:20px;
  color:#fff;
  text-shadow:2px 2px 0 rgba(0,0,0,0.5);
  margin-top:0;
}
h3{
  color:#fff;
  font-weight:normal;
  border-bottom:3px solid rgba(255,255,255,0.3);
}
.container{
  background:#dedede;
  width:200px;
  padding:10px;
  min-height:100px;
  line-height:95px;
  margin:10px;
  float:left;
  -mox-box-shadow:0 0 10px rgba(0,0,0,0.5);
  -webkit-box-shadow:0 0 10px rgba(0,0,0,0.5);
  box-shadow:0 0 10px rgba(0,0,0,0.5);
}
.container > span{
  display:inline-block;
  line-height:20px;
  vertical-align:middle;
  color:#4B4B4B;
}
.box-wrapper{
  overflow:hidden;
}
pre{
  background:rgba(255,255,255, 0.5);
  color:rgba(0,0,0,1);
  padding:10px;
}
            
          
!
999px
Loading ..................

Console