css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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

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

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              h1 CSS Grid Layout - Item Placement and Absolute Positioning

div.grid
  div.item.one
    h2 Grid Item One
    p This grid-item is placed on the grid using numeric indexes
  div.item.two
    h2 Grid Item Two
    p This grid-item is placed using auto placement. It will occupy the first empty grid cell available.
  div.item.three
    h2 Grid Item Three
    p This grid-item also uses auto placement but its size is determined using spans declared on its grid-area proprty. 
  div.item.four
    h2 Grid Item Four
    p This grid-item is aboslutely positioned relative to the grid container. The offset properties determine offsets inwwards from the edge of the containing block.
    p Absolutely positioned elements that are children of a grid container can be aligned to the its grid lines however the absolutely positioned element doesn't take up space in the grid or effect the layout of other grid items.
  div.item.five
    p Grid Item Five is also using numeric indexes for placement. Its z-index places it above the absolutely positioned element above it. 
    
    
            
          
!
            
              html,body{
  margin: 0;
  padding: 0;
}

body{
  background: linear-gradient(rgba(13,44,86,1),rgba(13,44,86,.90));
  color: #06162B;
}

*{
  box-sizing: border-box;
  font-family: Gill Sans;
}

h1{
  color: #fafafa;
  width: 70vw;
  text-align: center;
  margin: 1rem auto;
  font-size: 1.4rem;
}

p{
  font-size: 1.125rem;
}

.grid{
  //grid stuff
  display: grid;
  grid-template-columns: repeat(2, 1fr) 12rem 1fr; 
  grid-template-rows: repeat(6, 1fr) min-content;
  grid-gap: .5rem;
  
  //creating abspos containing block
  position: relative;
  
  height: 30%;
  min-height: 90vh;
  width: 90vw;
  margin: 0 auto;
  background: #F6511D;
}

.item{
  padding: .5rem;
  color: #06162B;
  box-shadow: 2px -3px 5px 0 rgba(0,0,0,.4);
}

.one{
  background: #7FB800; 
  grid-area: 2 / 1 / 3 / 3;
}

.two{
  height: 200px;
  width: 300px;
  background: #00A6ED;
}

.three{
  grid-area: span 3 / span 2;
  background: #00A6ED;
}

.four{
  grid-area: 3 / 1 / -1 / -1;
  color: #0D2C54;
  background: rgba(255,255,255,.5);
  position: absolute;
  top: 20px;
  bottom: 60px;
  left: 30px;
  right: 30px;
}

.five{
  grid-area: 6 / 1 / -1 / -1;
  background: #7FB800;
  z-index: 100;
  box-shadow: 0 -3px 5px 0 rgba(0,0,0,.4);
  
  p{
    margin: 0;
  }
}


            
          
!
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