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

              
                // The concept of this project was to create modular HTML and CSS code that could be used to create sophisticated, responsive, magazine-style website designs. Each section includes its own modular code that can be plugged into any website and customized; the general styles of the module remain the same. The modules are created with CSS Grid and some newer properties (e.g., position: sticky). No JS has been used to create these layouts. Each module can be found in the Layout Central collection here on CodePen: https://codepen.io/collection/DJJxjw/


// taken from
// https://codepen.io/brianhaferkamp/pen/ZZvLoy

.two-thirds-image-left-one-third-text-right
  .image
    img(src="https://source.unsplash.com/1600x900")
  .text
    h1.title Marley's Ghost
    h2.lead Marley was dead: to begin with. There is no doubt whatever about that. The register of his burial was signed by the clergyman
    p The Nellie, a cruising yawl, swung to her anchor without a flutter of the sails, and was at rest. The flood had made, the wind was nearly calm, and being bound down the river, the only thing for it was to come to and wait for the turn of the tide.

    p The sea-reach of the Thames stretched before us like the beginning of an interminable waterway. In the offing the sea and the sky were welded together without a joint, and in the luminous space the tanned sails of the barges drifting up with the tide seemed to stand still in red clusters of canvas sharply peaked, with gleams of varnished sprits. A haze rested on the low shores that ran out to sea in vanishing flatness. The air was dark above Gravesend, and farther back still seemed condensed into a mournful gloom, brooding motionless over the biggest, and the greatest, town on earth.

    p The Director of Companies was our captain and our host. We four affectionately watched his back as he stood in the bows looking to seaward. On the whole river there was nothing that looked half so nautical. He resembled a pilot, which to a seaman is trustworthiness personified. It was difficult to realize his work was not out there in the luminous estuary, but behind him, within the brooding gloom.

    p Between us there was, as I have already said somewhere, the bond of the sea. Besides holding our hearts together through long periods of separation, it had the effect of making us tolerant of each other’s yarns—and even convictions. The Lawyer—the best of old fellows—had, because of his many years and many virtues, the only cushion on deck, and was lying on the only rug. The Accountant had brought out already a box of dominoes, and was toying architecturally with the bones. Marlow sat cross-legged right aft, leaning against the mizzen-mast. He had sunken cheeks, a yellow complexion, a straight back, an ascetic aspect, and, with his arms dropped, the palms of hands outwards, resembled an idol. The director, satisfied the anchor had good hold, made his way aft and sat down amongst us. We exchanged a few words lazily. Afterwards there was silence on board the yacht. For some reason or other we did not begin that game of dominoes. We felt meditative, and fit for nothing but placid staring. The day was ending in a serenity of still and exquisite brilliance. The water shone pacifically; the sky, without a speck, was a benign immensity of unstained light; the very mist on the Essex marsh was like a gauzy and radiant fabric, hung from the wooded rises inland, and draping the low shores in diaphanous folds. Only the gloom to the west, brooding over the upper reaches, became more sombre every minute, as if angered by the approach of the sun.

    p And at last, in its curved and imperceptible fall, the sun sank low, and from glowing white changed to a dull red without rays and without heat, as if about to go out suddenly, stricken to death by the touch of that gloom brooding over a crowd of men.

    p Forthwith a change came over the waters, and the serenity became less brilliant but more profound. The old river in its broad reach rested unruffled at the decline of day, after ages of good service done to the race that peopled its banks, spread out in the tranquil dignity of a waterway leading to the uttermost ends of the earth. We looked at the venerable stream not in the vivid flush of a short day that comes and departs for ever, but in the august light of abiding memories. And indeed nothing is easier for a man who has, as the phrase goes, “followed the sea” with reverence and affection, than to evoke the great spirit of the past upon the lower reaches of the Thames. The tidal current runs to and fro in its unceasing service, crowded with memories of men and ships it had borne to the rest of home or to the battles of the sea. It had known and served all the men of whom the nation is proud, from Sir Francis Drake to Sir John Franklin, knights all, titled and untitled—the great knights-errant of the sea. It had borne all the ships whose names are like jewels flashing in the night of time, from the Golden Hind returning with her rotund flanks full of treasure, to be visited by the Queen’s Highness and thus pass out of the gigantic tale, to the Erebus and Terror, bound on other conquests—and that never returned. It had known the ships and the men. They had sailed from Deptford, from Greenwich, from Erith—the adventurers and the settlers; kings’ ships and the ships of men on ‘Change; captains, admirals, the dark “interlopers” of the Eastern trade, and the commissioned “generals” of East India fleets. Hunters for gold or pursuers of fame, they all had gone out on that stream, bearing the sword, and often the torch, messengers of the might within the land, bearers of a spark from the sacred fire. What greatness had not floated on the ebb of that river into the mystery of an unknown earth!… The dreams of men, the seed of commonwealths, the germs of empires.

    p The sun set; the dusk fell on the stream, and lights began to appear along the shore. The Chapman light-house, a three-legged thing erect on a mud-flat, shone strongly. Lights of ships moved in the fairway—a great stir of lights going up and going down. And farther west on the upper reaches the place of the monstrous town was still marked ominously on the sky, a brooding gloom in sunshine, a lurid glare under the stars.

    p “And this also,” said Marlow suddenly, “has been one of the dark places of the earth.”
    
    
// taken from 
// https://codepen.io/brianhaferkamp/pen/MRmXqV

section.one-by-one
  .image
    img(src="https://source.unsplash.com/1600x900/?chair", alt="")
  .image
    img(src="https://source.unsplash.com/1600x900/?bowl", alt="")
    
    
// original code

section.three-col-text
  p Between us there was, as I have already said somewhere, the bond of the sea. Besides holding our hearts together through long periods of separation, it had the effect of making us tolerant of each other’s yarns—and even convictions. The Lawyer—the best of old fellows—had, because of his many years and many virtues, the only cushion on deck, and was lying on the only rug. The Accountant had brought out already a box of dominoes, and was toying architecturally with the bones. Marlow sat cross-legged right aft, leaning against the mizzen-mast. He had sunken cheeks, a yellow complexion, a straight back, an ascetic aspect, and, with his arms dropped, the palms of hands outwards, resembled an idol. The director, satisfied the anchor had good hold, made his way aft and sat down amongst us. We exchanged a few words lazily. Afterwards there was silence on board the yacht. For some reason or other we did not begin that game of dominoes. We felt meditative, and fit for nothing but placid staring. The day was ending in a serenity of still and exquisite brilliance. The water shone pacifically; the sky, without a speck, was a benign immensity of unstained light; the very mist on the Essex marsh was like a gauzy and radiant fabric, hung from the wooded rises inland, and draping the low shores in diaphanous folds. Only the gloom to the west, brooding over the upper reaches, became more sombre every minute, as if angered by the approach of the sun.

    p And at last, in its curved and imperceptible fall, the sun sank low, and from glowing white changed to a dull red without rays and without heat, as if about to go out suddenly, stricken to death by the touch of that gloom brooding over a crowd of men.

    p Forthwith a change came over the waters, and the serenity became less brilliant but more profound. The old river in its broad reach rested unruffled at the decline of day, after ages of good service done to the race that peopled its banks, spread out in the tranquil dignity of a waterway leading to the uttermost ends of the earth. We looked at the venerable stream not in the vivid flush of a short day that comes and departs for ever, but in the august light of abiding memories. And indeed nothing is easier for a man who has, as the phrase goes, “followed the sea” with reverence and affection, than to evoke the great spirit of the past upon the lower reaches of the Thames. The tidal current runs to and fro in its unceasing service, crowded with memories of men and ships it had borne to the rest of home or to the battles of the sea. It had known and served all the men of whom the nation is proud, from Sir Francis Drake to Sir John Franklin, knights all, titled and untitled—the great knights-errant of the sea. It had borne all the ships whose names are like jewels flashing in the night of time, from the Golden Hind returning with her rotund flanks full of treasure, to be visited by the Queen’s Highness and thus pass out of the gigantic tale, to the Erebus and Terror, bound on other conquests—and that never returned. It had known the ships and the men. They had sailed from Deptford, from Greenwich, from Erith—the adventurers and the settlers; kings’ ships and the ships of men on ‘Change; captains, admirals, the dark “interlopers” of the Eastern trade, and the commissioned “generals” of East India fleets. Hunters for gold or pursuers of fame, they all had gone out on that stream, bearing the sword, and often the torch, messengers of the might within the land, bearers of a spark from the sacred fire. What greatness had not floated on the ebb of that river into the mystery of an unknown earth!… The dreams of men, the seed of commonwealths, the germs of empires.
    
    
// taken from
// https://codepen.io/brianhaferkamp/pen/vMmrbO
    
section.wide-tall-cap-left
  .image.image-1
    img(src="https://source.unsplash.com/1600x900/?man", alt="")
  .caption.caption-1
    p The Nellie, a cruising yawl, swung to her anchor without a flutter of the sails, and was at rest. The flood had made, the wind was nearly calm, and being bound down the river, the only thing for it was to come to and wait for the turn of the tide.
    p The sea-reach of the Thames stretched before us like the beginning of an interminable waterway.
  .image.image-2
    img(src="https://source.unsplash.com/900x1600/?man", alt="")
  .caption.caption-2
    p The Nellie, a cruising yawl, swung to her anchor without a flutter of the sails, and was at rest. The flood had made, the wind was nearly calm, and being bound down the river, the only thing for it was to come to and wait for the turn of the tide.
              
            
!

CSS

              
                // Universal

@import url("https://fonts.googleapis.com/css?family=Merriweather:400,400i,700")

body
  font-family: Merriweather, serif

img
  width: 100%
  display: block
  
p
  line-height: 1.3

  @media (min-width: 1170px)
    font-size: 1.2rem
    
    
// taken from
// https://codepen.io/brianhaferkamp/pen/ZZvLoy
  
.two-thirds-image-left-one-third-text-right
  position: relative
  
  @media (min-width: 700px)
    display: grid
    grid-template-columns: repeat(12, 1fr)
    grid-column-gap: 1rem
    
  @media (min-width: 1170px)
    grid-column-gap: 2rem
    
  .image
    @media (min-width: 700px)
      grid-column: 1 / 8
      height: 100%
      
      img
        height: 100vh
        object-fit: cover
        position: sticky
        top: 0
        
    @media (min-width: 1170px)
      grid-column: 1 / 9
  
  .text
    padding: 1rem
    
    @media (min-width: 700px)
      grid-column: 8 / span all
      
    @media (min-width: 1170px)
      grid-column: 9 / span all
    
    .title
      font-size: 3rem
      margin: 2rem 0
      
      @media (min-width: 700px)
        font-size: 4rem
    
    .lead
      font-style: italic
      font-weight: 400
      font-size: 1.2rem
      margin: 1rem 0 3rem
      line-height: 1.5
      
      @media (min-width: 700px)
        font-size: 1.4rem
        
        
// taken from 
// https://codepen.io/brianhaferkamp/pen/MRmXqV
  
.one-by-one
  display: grid
  grid-template-columns: 1fr
  grid-gap: .5rem
  margin: .5rem
    
    
// taken from
// https://codepen.io/brianhaferkamp/pen/vMmrbO
  
.wide-tall-cap-left
  display: grid
  grid-template-columns: 1fr
  grid-gap: .5rem
  margin: .5rem
    
  @media (min-width: 600px)
    grid-template-columns: repeat(12, 1fr)
    
  @media (min-width: 600px)
    .image-1
      grid-row: 1
      grid-column: 1 / -1
    
  @media (min-width: 600px)
    .image-2
      grid-row: 2
      grid-column: 6 / span 7
    
  .caption
    max-width: 70vw
    
    @media (min-width: 600px)
      font-size: .8rem
      margin: 2rem .5rem
    
  @media (min-width: 600px)
    .caption-1
      grid-row: 2
      grid-column: 1 / span 2
      
  @media (min-width: 600px)
    .caption-2
      grid-row: 2
      grid-column: 3 / span 2
      
      
// original code

.three-col-text
  columns: 3
  column-width: 300px
  padding: 1rem
  
  p
    &:first-child
      margin-top: 0
              
            
!

JS

              
                // no JS needed!
              
            
!
999px

Console