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.

Quick-add: + add another resource

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.

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