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

              
                <!-- container all the item -->
<div class="css-masonry">
     
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">1</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-collage-01.jpg">
    <!-- title if title -->  
    <div class="title">
        This is a pure CSS only responsive masonry grid.
        <p class="french">Un grid masonry en pure css</p>
      </div>
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">2</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-photography-copenhague.jpg">
        <div class="title">
        Copenhagen
      </div>  
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">3</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-photographie-pete-the-monkey.jpg">
       <div class="title">
           <a href="instagram.com/quentinrenaux" target="_blank">Visit my instagram</a>
      </div>    
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">4</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-collage-dessin-01.jpg">
      <div class="title">
           Draw
      </div>    
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">5</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-desk-3D.jpg">
      <div class="title">
           3D table 
      </div>   
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">6</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-collage-dessin-radiateur-01.jpg">
      <div class="title">
           Mask search
      </div>   
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">7</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-collage-dessin-lignes.jpg">
      <div class="title">
           Lines on photography<br>
salut
      </div>   
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">8</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-photographie-benoit-thomas.jpg">
      <div class="title">
           Brother
      </div>   
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">9</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-collage-main-pantin.jpg">
      <div class="title">
           Display
      </div>   
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">10</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-musique-photographie-clement.jpg">
      <div class="title">
           At work
      </div>   
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">11</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-collage-dessin-ligne-02.jpg">
      <div class="title">
           Lines #2
      </div>   
  </div>
    
  <!-- item -->
  <div class="item">
    <!-- number of the item -->
    <div class="item-number">12</div> 
    <!-- image -->
    <img src="https://quentinrenaux.com/wp-content/uploads/2020/11/quentin-renaux-instagram-collage-dessin-lignes-makeup-03.jpg">
    <!-- title if title -->  
    <div class="title">
        The photography are from my instagram
        <p class="french">Les photographies sont visibles sur mon insta</p>
    </div>  
  </div>
    
    <!-- item -->
  <div class="item"> 
    <div class="title">
        Css Masonry
        <p class="french"><a href="https://quentinrenaux.com/category/webexperiments/" target="_blank">Check the other articles</a>
<br><br>
          All the photography & drawing are copyright : <a href="https://instagram.com/quentinrenaux" target="_blank">@quentinrenaux</a></p>
    </div>  
  </div>
    
</div>
              
            
!

CSS

              
                
/* Welcome here, 
 * you can say hello 
 * or see other projects like this 
 * at quentinrenaux.com
 * and we can speak at    
 * twitter : @quentinrenaux 
 * insta : @quentinrenaux
 */

@import url('https://fonts.googleapis.com/css2?family=Alata&display=swap');

/* BASIC CODE  
 * ------------------ */
*, div, p, img {  
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
}

/* BODY CODE  
 * ------------------ */
body {
    font-family: sans-serif;
    margin: 0;
    background: #ddd;
    }

/* MASONRY GRID 
 * ------------------ */
.css-masonry { 
    -webkit-column-count: 4;
    -moz-column-count:4;
    column-count: 4;
    
    -webkit-column-gap: 1em;
    -moz-column-gap: 1em;
    column-gap: 1em;
    
    -moz-column-gap: 1.5em;
    -webkit-column-gap: 1.5em;    
    column-gap: 1.5em;
    
    margin: 1.5em;    
    padding: 0;
    font-size: .85em;
}

/* ITEM 
 * ------------------ */
.item {
    display: inline-block;
    width: 100%;
    
    font-family: 'Alata', sans-serif;
    font-size: 1.8em;
    
    background: #fff;
    margin: 0 0 1em;
    width: 100%;
    
	-webkit-transition:1s ease all;

    border: 2px solid black;
    border-radius: 6px; 
    overflow: hidden; /* to affect the inner elements with the radius */
}

.item img{ max-width:100%; font-size: 0; height: auto; /* to be sure to don't have a spacing after the img due to the inline block function */ }

.item-number {
    border: 2px solid black;
    border-radius: 50%;
    background: #fff;
    
    
    font-size: 0.8em;
    display: flex; /* flex is for center verticaly and horizontaly the number */
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    padding: 0 2px 2px 0; /* I display right and bottom padding because of the font who is not center par default : delete if you change the font */
    
    position: absolute;
    margin: 5px;
}

.item .title {
    border: 0px solid blue;
    padding: 10px 10px 14px;
}

.french {color: grey; font-size: 0.8em;}

@media only screen and (max-width: 420px) {
    .css-masonry {
        -moz-column-count: 1;
        -webkit-column-count: 1;
        column-count: 1;
    }
}

@media only screen and (min-width: 421px) and (max-width: 768px){
    .css-masonry {
        -moz-column-count: 2;
        -webkit-column-count: 2;
        column-count: 2;
    }
}
@media only screen and (min-width: 769px) and (max-width: 1000px){
    .css-masonry {
        -moz-column-count: 3;
        -webkit-column-count: 3;
        column-count: 3;
    }
}
@media only screen and (min-width: 1001px) {
    .css-masonry {
        -moz-column-count: 4;
        -webkit-column-count: 4;
        column-count: 4;
    }
}
              
            
!

JS

              
                
              
            
!
999px

Console