startv

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
via CSS Lint

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
via JS Hint

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Want a Run Button?

If active, the preview will update automatically when you change code.

HTML

            
              <dl class="fields two">
  <dt>Label 1A</dt>
  <dd>First data field</dd>
  <dt>Label 1B</dt>
  <dd>Second much longer data field</dd>
</dl>
<dl class="fields five">
  <dt>Label 2A</dt>
  <dd>Data 2A</dd>
  <dt>Label 2B</dt>
  <dd>Data 2B may contain data wider than other cells</dd>
  <dt>Label 2C</dt>
  <dd>Data 2C</dd>
  <dt>Label 2D</dt>
  <dd>Data 2D</dd>
  <dt>Label 2E</dt>
  <dd>2E</dd>
</dl>
<dl class="fields three">
  <dt>Label 3A<br />Label 3A Second Line</dt>
  <dd>3A</dd>
  <dt>Label 3B</dt>
  <dd>3B with a long data field but a short label field</dd>
  <dt>Label 3C</dt>
  <dd>3C</dd>
</dl>
    
            
          
!

CSS

            
              /*

This is a nice example on why you probably don't want to mimic table style.

*/

dl.fields {
  /* complete inline-block hack */
  font-size: 0;
  -webkit-font-size-adjust: none;
  letter-spacing: -.25em;
  word-spacing: -.25em;
  
  /* generic resets */
  border: 2px solid #CCC;
  margin: -2px;
  padding: 0;
  position: relative;
  width: 100%;
  z-index: 1;
}

dl.fields > * {
  /* complete inline-block hack */
  font-size: medium;
  -webkit-font-size-adjust: auto;
  letter-spacing: 0;
  word-spacing: 0;
  
  /* generic resets */
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: inline-block;
  margin: 0;
  padding: 0;
}

dl.two > *,
dl.two > dd:before,
dl.two > dd:after { width: 50%; }
dl.three > *,
dl.three > dd:before,
dl.three > dd:after { width: 33.333%; }
dl.four > *,
dl.four > dd:before,
dl.four > dd:after { width: 25%; }
dl.five > *,
dl.five > dd:before,
dl.five > dd:after { width: 20%; }

dl.two > dt { margin-right: -50%; }
dl.three > dt { margin-right: -33.333%; }
dl.four > dt { margin-right: -25%; }
dl.five > dt { margin-right: -20%; }

dl.fields > dt {
  background: #000;
  color: #FFF;
  font-size: 9pt;
  padding: .5em;
  position: relative;
  vertical-align: top;
  z-index: 2;
}

dl.fields > dd {
  margin: .5em  0;
  padding: 2.5em .5em 1em .5em;
  vertical-align: text-top;
}

/* pseudo elements to create a full height background */
dl.fields > dd:before,
dl.fields > dd:after{
  content: '';
  display: block;
  font-size: medium;
  height: 100%;
  margin-left: -.5em;
  position: absolute;
  top: 0;
  z-index: -1;
}

/* background colors */
dl.fields > dd:nth-of-type(odd):before { background: #FFF; }
dl.fields > dd:nth-of-type(even):before { background: #EEE; }

/* background color on hover */
dl.fields > dd:hover:before { background: #ABC; }

/* enable :hover on whole height */
dl.fields > dd:after { z-index: 1; }
dl.fields > dd:hover:after { z-index: -1; }
            
          
!

JS

            
              
            
          
!
999px
Loading ..................

Console