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.

            
              <div class="grid">
<div class="item">
  <h2>Basketball</h2>
  <p>Basketball is a non-contact sport played on a rectangular court.</p>
</div>
<div class="item">
  <h2>Team sport</h2>
  <p>Most often played as a team sport with five players on each side.</p>
</div>
<div class="item">
  <h2>Objective</h2>
  <p>The objective is to shoot a ball through a hoop that is mounted to a backboard at each end of the court. </p>
</div>
<div class="item">
  <h2>Creation</h2>
  <p>The game was invented in 1891 by Dr. James Naismith.</p>
</div>
<div id="hero" class="item">
  <p>An outdoor basketball net</p>     
</div>
</div> <!-- /l-grid -->
<div class="main">
<p class="credit">All text and images from Wikipedia.</p>
 </div> <!-- /l-main -->
            
          
!
            
              // rules for general styling only 

body { 
  font-family: Georgia, serif; 
  font-size: 120%;
  line-height: 1.333;
  hyphens: auto;
  color: #331408;
  background-color: #331408; 
}

h1,h2,h3 { 
  font-family: Impact, Helvetica, sans-serif;
  text-transform: uppercase; 
  letter-spacing: 0.1em;
}

.item {border-radius: 0.333em;}

#hero {
  display: flex;
  flex-direction: column;
  p { 
    margin-top: auto;
    color: #FAB280;
    font-size: 80%;
    font-weight: bold;
  }
}

* { 
  box-sizing: border-box;
}

// all styling for the grid layout

.grid {
  padding: 1em;
  display: grid;
  // set each row to equal height
  grid-template-rows: 1fr 1fr 1fr 1fr 1fr;
  grid-gap: 1em;
  @media screen and (min-width: 24em) {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 16em 16em 16em;
  }
  @media screen and (min-width: 48em) {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 16em 16em;
  }
}

.item { 
  @media screen and (max-width: 48em) { order: 3; }
  padding: 0em 1em;
  background: #FAB280;
}

.item:nth-child(1) {
  @media screen and (max-width: 48em) { order: 1; }
}

.item:nth-child(2) {
  @media screen and (min-width: 24em) and (max-width: 48em) { order:1; }
}

#hero { 
  @media screen and (min-width: 24em) {
    grid-column-start: 1;
    grid-column-end: span 2;
  }
  @media screen and (min-width: 48em) {
    grid-column-start: 2;
    grid-column-end: span 2;
  }
  @media screen and (max-width: 48em) { order:2; }
  // background image with dark tinted gradient at the bottom for better readability of text
  background-image: linear-gradient(-180deg, rgba(0,0,0,0.00) 70%, rgba(0,0,0,0.67) 100%), url(https://upload.wikimedia.org/wikipedia/commons/4/4e/Basketball_Goal.jpg);
  background-size:cover;
  background-position: center;
}

.main {
  padding: 1em;
}

.credit {
  font-size: 90%;
  color: gray;
}
            
          
!
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