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>Responsive grid layout with differing heights - all CSS</h1>
<h3>The classes are displayed inside the blocks</h3>
<ul class="portfolio-items">
  <li class="portfolio-item quarter double-height">
  </li>
  <li class="portfolio-item quarter responsive-half">
  </li>
  <li class="portfolio-item half">
  </li>
  <li class="portfolio-item half">
  </li>
  <li class="portfolio-item quarter">
  </li>

  <!-- second block -->
  <li class="portfolio-item quarter double-height float-right">
  </li>
  <li class="portfolio-item half">
  </li>
  <li class="portfolio-item quarter responsive-half">
  </li>
  <li class="portfolio-item quarter">
  </li>
  <li class="portfolio-item half">
  </li>
  <li class="portfolio-item full">
  </li>
  <li class="portfolio-item two-third">
  </li>
  <li class="portfolio-item third">
  </li>
</ul>
            
          
!
            
              .portfolio-items {
  max-width: 2000px;
  width: 100%;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.portfolio-item {
  display: block;
  height: 300px;
  border: 2px solid #fff;
  list-style: none;
  background: #47a3da;
  float: left;
  box-sizing: border-box;
}

/* different sizes */
.full {
  width: 100%;
  background: #d35400;
}
.two-third {
  width: 66.666%;
  background: #27ae60;
}
.half {
  width: 50%;
  background: #c0392b;
}
.third {
  width: 33.333%;
  background: #16a085;
}
.quarter {
  width: 25%;
  background: #34495e;
}

/* extra classes */
.double-height {
  height: 600px;
  background: #7f8c8d;
}
.float-right {
  float: right;
}

@media all and (max-width: 900px) {
  .half,
  .responsive-half.responsive-half {
    /* Override .responsive-half's other classes */
    width: 66.666%;
  }
  .quarter {
    width: 33.333%;
  }
}

@media all and (max-width: 600px) {
	.portfolio-item.portfolio-item { /* Override all other settings */
		width: 50%;
		height: 300px; /* override different height-classes */
	}
}

@media all and (max-width: 400px) {
	.portfolio-item.portfolio-item { /* Override all other settings */
		width: 100%;
	}
}


/* non-essential code, just for fun */
.portfolio-items {
  resize: horizontal;
}
h1, h2, h3 {
  text-align: center;
  font-family: "Roboto Slab", Times, serif;
}
.portfolio-item {
  position: relative;
  opacity: .9;
  transition: opacity .2s ease-in-out;
}
.portfolio-item:hover {
  opacity: 1;
}
.portfolio-item:before {
  position: absolute;
  top: 50%;
  width: 100%;
  transform: translateY(-50%);
  text-align: center;
 
  content: attr(class);
  color: #fff;
  font-size: 2em;
  font-family: Raleway, Calibri, Arial, sans-serif;
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console