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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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

.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 {
    content: "";
    display: block;
    width: 1px;
    margin-left: -1px;
    float: left;
    height: 0;
    padding-top: 67%;
  }
  
  &__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
Loading ..................

Console