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

              
                <div class="wrapper">
  <div class="column">
    <div class="feature-box" style="background-image: url(https://i0.wp.com/daviddickball.uk/wp-content/uploads/2017/12/Screen-Shot-2017-12-03-at-21.47.59.png?zoom=3&resize=825%2C510);">
      <div class="feature-box__tint"></div>
      <div class="feature-box__content">
        <h2 class="feature-box__title">This box maintains its aspect ratio</h2>
        <p>This text is aligned to the bottom using flexbox. This container will maintain aspect ratio, except if it's too small to contain the text, in which case it'll expand.</p>
        <a href="#" class="button feature-box__cta">Click here</a>
      </div>

    </div>
  </div>
  
  <div class="column">
    <div class="feature-box" style="background-image: url(https://i2.wp.com/daviddickball.uk/wp-content/uploads/2016/12/unstable-6x4.png?resize=825%2C510);">
      <div class="feature-box__tint"></div>
      <div class="feature-box__content">
        <h2 class="feature-box__title">The reason we don't use position absolute</h2>
        <p>To align this text to the bottom is because the container won't know how big to be, so might clip the text if it's small (on tablet or small desktop). This way, it expands to always show the text.</p>
      <a href="#" class="button feature-box__cta">Click here</a>
      </div>

    </div>
  </div>
  
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Merriweather+Sans:400,700');

html,body {
  font-family: 'Merriweather Sans', sans-serif;
  color: white;
}

.column {
  $column-gap: 2rem;
  width: calc(50% - #{$column-gap / 2});
  margin-right: $column-gap;
  float: left;
  
  &:last-child {
    margin-right: 0;
  }
}

.wrapper {
  padding: 2rem;
  max-width: 1400px;
  margin: auto;
}

.feature-box {
  position: relative;
  padding: 20px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  background: no-repeat center;
  background-size: cover;
  margin-bottom: 2rem;
  
  &:before {
    //--this forces the aspect ratio
    content: "";
    display: block;
    width: 1px;
    margin-left: -1px;
    float: left;
    height: 0;
    padding-top: 67%; //--(height/width) * 100
  }
  
  &__title {
    font-size: 28px;
    margin: 0 0 0.5rem;
    font-weight: bold;
  }
  
  &__cta {
    margin-top: 1rem;
    
  }
  
  &__tint {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparentize(#336699, 0.07);
  }
  
  &__content {
    position: relative;
    z-index: 1;
    line-height: 1.5;
    
    p {
      margin-bottom: 0;
    }
  }
}

.button,
a.button{
  border-radius: 5px;
  background: #FFFA38;
  padding: 10px 20px;
  color: black;
  font-weight: bold;
  text-decoration: none;
  display: inline-block;
}
              
            
!

JS

              
                
              
            
!
999px

Console