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.

            
              <div class="container">
  <header>
    <h2>Simple 'holy grail' layout</h2>
  </header>

  <div class="right-col">
    <div class="center-col">
      <div class="left-col">
        <article class="center">
          <h3>When divs Attack.</h3>
          <p>Semantically, I'm a fan of something I heard in an FITC conference I attended a few years back. </p>
          <blockquote>If you're nesting your HTML more than 3 divs deep, you're doing it wrong.</blockquote>
          <p>I'd amend that to up to 5 now, having worked with Angular apps and around their requirements, as well as with complex site layouts. Keeping it to 3 is great, until you have to do something like this layout.</p>
    
          <p>This is a great flexible, % based layout that's pretty hard to screw up. It's entirely inspired by <a href="http://matthewjamestaylor.com/blog/perfect-3-column.htm" target="_blank">Matthew James Taylor</a>, with some additions for mobile layout first. I've added all the things in a media query to keep mobile simple; no one needs to define all that and then hide it for mobile. That's insanity.</p>
    
          <p>If you didn't come from the Flex version of this, look to your right (not in the room, over there in the column), and find a link to it. </p>
        </article>
 
        <aside class="left">
          Look ma, short text!
        </aside>
    
        <aside class="right">
          <p>Flex version of this layout. A bit more risky especially in older browsers, but feeds the semantic OCD in me:</p>
          <p><a href="https://codepen.io/fay-lisa/pen/ZpGvzL" target="_blank">Flex magicks</a>
        </aside>
      </div>
    </div>
  </div>

  <footer>
    <ul> 
      <li>
       This will work in everything. Even iPad, iPhone, and *gasp* IE theoretically down to 7. Hide your children.
     </li>
    </ul>
  </footer>
</div>
            
          
!
            
              // relatively simple 3 column holy grail layout, with nearly unlimited support in browser and mobile
.container {
  width: 100%;
  
  // add styling for each section for mobile: 
  header {
    background: #b6b6b6;
  }
  
  .left {
    background: #c6c5c3; // making this a bit darker on mobile so the columns have separation without borders
  }

  .center {
    background: #e2e1dd;
  }
    
  .right {
    background: #d5d3d0;
  }
  
  footer {
    background: #c6c5c3;
  }
  
  // shared padding for mobile
  header, footer, article, aside {
    width: 100%;
    padding: 10px;
  }

  
  // now we change layout for larger than phone screens (ipad, ipad mini, larger phablets)
  @media all and (min-width: 600px) {
    
    .right-col {
      clear: both;
      overflow: hidden;
    }
    
    // elements all the 'column' containers share: 
    .right-col,
    .center-col,
    .left-col {
      width: 100%;
      float: left;
		  position: relative;
    }
    
    .right-col {
      background: #d5d3d0; // colors the right column in the end
    }
    
    .center-col {
      right: 20%;
      background: #e2e1dd; // colors the center column in the end
    }
    
    .left-col {
      right: 60%;
      background: #d5d3d0; // colors the left column in the end
    }
    
    .center, .left, .right {
      float: left;
		  position: relative;
      background: transparent; // this gets rid of the mobile bkgs, as they now use the new magic for ipad and up
      padding: 10px 0;
    }
    
    .center {
      width: 55%; // width of the center column content
		  left: 101%;
    }
    
    .left {
      width: 18%; // width of the left column content
		  left: 26%;	
    }
    
    .right {
      width: 18%; // width of the right column content
		  left: 88%;
    }
    
    footer {
      clear: both;
    }
  }
}


// basic styling. 
body {
  font-family: Helvetica, Arial, sans-serif;
  background: aliceblue;
  line-height: 19px;
}
* {
  box-sizing: border-box;
}
//a tags 
a {
  color: #ab0d58;
  padding: 2px;
}
h2, footer {
  text-align: center;
}
h2 {
  margin: 0;
  padding: 30px 0;
}
h3 {
  margin: 0 0 10px 0;
}
p {
  margin: 5px 0 20px;
}
ul {
  // getting rid of the browser default
  margin: 0;
  padding: 0;
  list-style-type: none;
  
  li {
    margin: 10px 5px;
    display: inline-block;
    padding: 5px;
  }
}
blockquote {
  background: #d5d3d0;
  padding: 20px;
}
            
          
!
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