cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <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>
            
          
!
            
              @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;
}
            
          
!
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