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.

            
              <main>
  <section class="cards">
   <div class="grid">
  <div class="cards__grid">
   <article class="card">
      <a class="card__link" href="https://youtu.be/IOaFh-yJk_k" target="_blank">
        <figure class="card__figure"><img src="https://source.unsplash.com/HzEb3ZRtV88/900x600"/></figure>
        <div class="card__content">
          <span class="card__meta link-nested" data-nested-link="https://codepen.io/StephenScaff/">Nested Link</span>
          <h3 class="card__title">Girls ain't nothing but trouble</h3>
          <p class="card__text">Listen homeboys don't mean to bust your bubble, but girls of the world ain't nothing but trouble.</p>
            
            <span class="card__btn">Read More</span>
        </div>
     </a>
  </article>
  
  <article class="card">
      <a class="card__link" href="https://youtu.be/OMnbw-AM4VA" target="_blank">
        <figure class="card__figure"><img src="http://source.unsplash.com/-udZnjsCzsE/900x600"/></figure>
        <div class="card__content">
          <span class="card__meta link-nested" data-nested-link="https://codepen.io/StephenScaff/">The Nested  Link</span>
          <h3 class="card__title">Nightmare on my street</h3>
          <p class="card__text">But when I got home and laid down to sleep, that began the nightmare, but on my street!</p>
            
            <span class="card__btn">Read More</span>
        </div>
     </a>
  </article>
  </div>
  </div>
</section>

<section class="content">
  <div class="grid">
    <p>If you see DJ Jazzy Jeff and the Fresh Prince, then you clicked the block level link. If you see my CodPen Home, you clicked the nested link.</p>
  </div>
</section>
</main>
            
          
!
            
              $font-header: Poppins, helvetica;

*, *:before, *:after {
  box-sizing: border-box; 
}

html, body{
  background: #efefef;
  font-family: $font-header;
}

body{
  margin: 0;
  width: 100%;
  font-weight: 400;
  font-style: normal;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale; 
  text-rendering: optimizeLegibility;
  
  // To improve embeded presentation
  @media (max-width: 76em) and (min-width: 40em) {
    font-size:80%;
  }
}

main{
  padding: 2em 0 4em;
}
a{
  text-decoration:none;
  color: #1c1c1c;
}

.link-nested{
  //z-index: 7;
  position: relative;
  display: block;
  margin-bottom: 0.5em;
  color: #2bd6de;
  cursor:pointer;
  transition: color 0.5s ease;
  
  &:hover{
    color: #aaa;
  }
}

.grid{
  margin: 0 auto;
  width: 95%;
  max-width: 60em;
}


.content{
  text-align:center;
  
  p{
    max-width: 39em;
    margin: 0 auto;
    padding: 0 2%;
  }
}

.cards{
  padding: 2em 0;
  
  &__grid{
    
    @media (min-width: 40em){
      display: flex;
      flex-direction: row;
      flex-flow: wrap;
      justify-content: center;
      margin: 0 -1em;
    }
  
    & > *{
      @media (min-width: 40em){
        width: 50%;
        max-width:50%;
        flex-basis:50%;
        padding: 1em;
      }
    }
  }
}


.card{
  position: relative;
  display:block;
  margin-bottom: 1em;
  
  &__link{
    position:relative;
    display: block;
    margin-bottom: 2em;
    transition: transform 0.5s ease-in-out;
    
    &:hover{
      transform: translate3d(0,-0.4em,0);
    }
    &:before{
      content:'';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height:100%;
      box-shadow: 0 0 4em rgba(0, 0, 0, 0.35);
      opacity: 0;
      transition: opacity 0.3s ease-in-out;
    }
    &:hover:before{
      opacity: 1;
    }
  }
  &__figure{
    margin: 0;
    
    img{
      display:block;
      width:100%;
      max-width: 100%;
    }
  }
  
  &__content{
    padding: 2em 2em;
    background: #fff;
    min-height: 21em;

  }
  &__meta{
    margin-bottom: 1em;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }
  
  &__title{
    margin: 0 0 0.25em;
    font-size: 1.7em;
    line-height: 1.4;
  }
  
  &__text{
    margin-bottom: 1em;
    color: #aaa;
  }
  &__btn{
    display:block;
    margin: 1em 0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #111;
    
    @media (min-width: 40em){
      position: absolute;
      bottom: 1em;
    }
  }

}
            
          
!
            
              
/**
 * Nested Links
 * Allows for links nested inside a block level link wrap
 * via a data attribute of the link location.
 * @author Stephen Scaff
 */
var NestedLinks = (function() {

  var nestedLinks = document.querySelectorAll('[data-nested-link]');

  return{
     
    /**
     * Init
     */
    init: function(){
      this.buildLink();
    },
 
    /**
     * Build Link
     * Constructs our nested link from our data attribute
     */
    buildLink: function(){
     
      Array.from(nestedLinks).forEach(function (nestedLink) {
        
        nestedLink.addEventListener('click', function (e) {
          var fakieLink = this.dataset.nestedLink;
          fakieLink && (e.preventDefault(), e.stopPropagation(), 
          window.open && e.metaKey ? window.open(fakieLink) : window.location.assign(fakieLink));
        });
      });
    },
  };
 })();
NestedLinks.init();
            
          
!
999px
Loading ..................

Console