Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Adaptable Flexbox Grid (Pure CSS)</h1>

<div class="o-flex-grid w-100 c-yellow">
    <div class="o-flex-grid--item"></div>
</div>

<div class="o-flex-grid w-100 c-blue">
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
</div>

<div class="o-flex-grid w-100 c-red">
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
</div>

<div class="o-flex-grid w-100 c-purple">
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
</div>

<div class="o-flex-grid w-100 c-orange">
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
</div>

<div class="o-flex-grid w-100 c-green">
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
    <div class="o-flex-grid--item"></div>
</div>
              
            
!

CSS

              
                *
    box-sizing: border-box
    
body
    font-family: "Avenir Next", "Avenir", "Helvetica Neue", "Helvetica", "Arial", sans-serif
    padding: 20px
    
h1
    font-size: 40px
    margin: 0 0 20px
    opacity: 0.1
    text-align: center
    
.c-yellow .o-flex-grid--item
    background: #f1c40f
.c-blue .o-flex-grid--item
    background: #3498db
.c-red .o-flex-grid--item
    background: #e74c3c
.c-purple .o-flex-grid--item
    background: #9b59b6
.c-orange .o-flex-grid--item
    background: #f39c12
.c-green .o-flex-grid--item
    background: #2ecc71
    
.o-flex-grid
    display: flex
    flex-shrink: 0
    justify-content: space-between
    margin: 0 auto
    
.o-flex-grid--item
    background: lightgrey
    border-radius: 5px
    box-shadow: 0 3px 6px rgba(0,0,0,0.2)
    margin: 5px
    padding: 20px
    
    &:first-child:nth-last-child(1)
    &:first-child:nth-last-child(1) ~ div
        width: 100%
        
    &:first-child:nth-last-child(2)
    &:first-child:nth-last-child(2) ~ div
        width: 50%
        
    &:first-child:nth-last-child(3)
    &:first-child:nth-last-child(3) ~ div
        width: 33%
        
    &:first-child:nth-last-child(4)
    &:first-child:nth-last-child(4) ~ div
        width: 25%
        
    &:first-child:nth-last-child(5)
    &:first-child:nth-last-child(5) ~ div
        width: 20%
        
    &:first-child:nth-last-child(6)
    &:first-child:nth-last-child(6) ~ div
        width: 16%
    
.w-100
    max-width: 1200px
    width: 100%
    
@media(max-width:800px)
    .o-flex-grid
        flex-direction: column
        flex-wrap: nowrap
        
    .o-flex-grid--item
        width: 100% !important
    
              
            
!

JS

              
                
              
            
!
999px

Console