cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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">
  <header>
    <nav>
      <h1>Card UI Example</h1>
    </nav>
  </header>
  <ul class="list loading">
    <li class="list-item">
      <div class="container">
        <div class="img init">
        <img data-id="EurOau9Mx6s" />
        </div>
        <h3>Title</h3>
        <p class="description">Lorem ipsum dolor sit amet, te aperiam mentitum vituperatoribus</p>
      </div>
    </li>
     <li class="list-item">
      <div class="container">
        <div class="img init">
        <img data-id="_4Ib-a8g9aA" />
        </div>
        <h3>Title</h3>
        <p class="description">Lorem ipsum dolor sit amet, te aperiam mentitum vituperatoribus</p>
      </div>
    </li>
     <li class="list-item">
      <div class="container">
        <div class="img init">
        <img data-id="x2-K3IL4VeA" />
        </div>
        <h3>Title</h3>
        <p class="description">Lorem ipsum dolor sit amet, te aperiam mentitum vituperatoribus</p>
      </div>
    </li>
     <li class="list-item">
      <div class="container">
        <div class="img init">
        <img data-id="aGpMJMpTQ1U" />
        </div>
        <h3>Title</h3>
        <p class="description">Lorem ipsum dolor sit amet, te aperiam mentitum vituperatoribus</p>
      </div>
    </li>
     <li class="list-item">
      <div class="container">
        <div class="img init">
        <img data-id="MXAKAcw1gSw" />
        </div>
        <h3>Title</h3>
        <p class="description">Lorem ipsum dolor sit amet, te aperiam mentitum vituperatoribus</p>
      </div>
    </li>
     <li class="list-item">
      <div class="container">
        <div class="img init">
        <img data-id="xi9TJ87x6ts" />
        </div>
        <h3>Title</h3>
        <p class="description">Lorem ipsum dolor sit amet, te aperiam mentitum vituperatoribus</p>
      </div>
    </li>
     <li class="list-item">
      <div class="container">
        <div class="img init">
        <img data-id="t1wcf52yEpY" />
        </div>
        <h3>Title</h3>
        <p class="description">Lorem ipsum dolor sit amet, te aperiam mentitum vituperatoribus</p>
      </div>
    </li>
     <li class="list-item">
      <div class="container">
        <div class="img init">
        <img data-id="n28nWI5PB5Q" />
        </div>
        <h3>Title</h3>
        <p class="description">Lorem ipsum dolor sit amet, te aperiam mentitum vituperatoribus</p>
      </div>
    </li>
     <li class="list-item">
      <div class="container">
        <div class="img init">
        <img data-id="TtrjiCTadOY" />
        </div>
        <h3>Title</h3>
        <p class="description">Lorem ipsum dolor sit amet, te aperiam mentitum vituperatoribus</p>
      </div>
    </li>
     
  </ul>
  <div class="page-container">
    <div class="page">
      <header class="page-header">
        <div class="btn-close"></div>
      </header>
      
    </div>
  </div>
  <div class="motion"></div>
</div>
<div class="bg"><span></span></div>
<div class="loading-anime">
  <div class="sk-fading-circle">
    <div class="sk-circle1 sk-circle"></div>
    <div class="sk-circle2 sk-circle"></div>
    <div class="sk-circle3 sk-circle"></div>
    <div class="sk-circle4 sk-circle"></div>
    <div class="sk-circle5 sk-circle"></div>
    <div class="sk-circle6 sk-circle"></div>
    <div class="sk-circle7 sk-circle"></div>
    <div class="sk-circle8 sk-circle"></div>
    <div class="sk-circle9 sk-circle"></div>
    <div class="sk-circle10 sk-circle"></div>
    <div class="sk-circle11 sk-circle"></div>
    <div class="sk-circle12 sk-circle"></div>
  </div>
</div>
            
          
!
            
              html,body{
  height:100%;
  width:100%;
  background:#f0f0f0;
  font-family: 'Armata', sans-serif;
}

.bg{
  position:absolute;
  top:0;
  left:0;
  z-index:0;
  width:100%;
  height:240px;
  overflow:hidden;
  background:rgba(0,0,0,1);
  
  span{
    display:block;
    width:120%;
    height:120%;
    margin:-5% auto auto -10%;
  background:url(https://source.unsplash.com/EurOau9Mx6s/400x300/) no-repeat center center;
  background-size:cover;
  filter:blur(10px);
    opacity:0.8;
  }
}

nav{
  width:100%;
  height:4rem;
  //background:#132e39;
  margin-bottom:1rem;
  h1{
    color:#fff;
    line-height:4rem;
    margin-left:1rem;
    text-align:center;
  }
}

.wrapper{
  height:100%;
  width:100%;
  padding-bottom:3rem;
  position:relative;
  z-index:2;
  .list{
    // display:flex;
    // flex-wrap:wrap;
    // justify-content:center;
    box-sizing:border-box;
    width:100%;
    margin:0 auto;
    
    
    &:after{
      content:"";
      display:table;
      clear:both;
    }
    
    &.loading{
     //display:none;
    }
  }
  
  .list-item{
    width:320px;
    //height:320px;
    margin:0 auto 8px;

    padding:0 4px;
    box-sizing:border-box;
    position:relative;
    transition:0.5s;
    top:0;
    cursor:pointer;
    
    
    &.init{
      top:24px;
      opacity:0;
    }
    
    &.hover{
        .container:after{
          background:rgba(0,0,0,0.5);
        }
    }
    
    .container{
      background:#fff;
      height:100%;
      border-radius:4px;
      overflow:hidden;
      //border:24px solid #1bb8d4;
      //box-sizing:border-box;
      padding-bottom:0.5rem;
      box-shadow:0 0 1px 0 rgba(0,0,0,0.1);
      position:relative;
      
      &:after{
        content:"";
        display:block;
        width:100%;
        height:100%;
        position:absolute;
        top:0;
        left:0;
        z-index:3;
        transition:0.3s;
      }
      
      
      
      h3{
        font-size:1rem;
        color:#333;
        margin:1rem;
      }

      .description{
        font-size:0.75rem;
        line-height:1.25;
        color:#999;
        margin:1rem;
      }
      
      .img.init{
        width:100%;
        background:#e0e0e0;
        &:before{
          content:"";
          display:block;
          //padding-top:75%;
          
        }
        
        img{
           opacity:0;
          
        }
      }
      img{
        opacity:1;
        width:100%;
        height:auto;
        transition: 3s;
        border-radius:4px 4px 0 0;
      }
    }
    
    
  }
  .page-container{
    display:none;
    width:100%;
    height:100%;
    position:fixed;
    top:0;
    left:0;
    //overflow-x:hidden;
    z-index:6;
    background-size:cover;
    //transition:1s;
  }
  .page{
    width:100%;
    
    .page-header{
      width:100%;
      height:48px;
      background:rgba(0,0,0,0.5);
    }
    
    .btn-close{
      cursor:pointer;
      //margin:1rem;
      width:48px;
      height:48px;
      position:fixed;
      top:0;
      right:0;
      
      &:before{
        content:"";
        display:block;
        height:1px;
        width:36px;
        background:#e0e0e0;
        transform-origin:top left;
        transform:rotate(45deg);
        position:absolute;
        top:12px;
        //left:-9px;
      }
      &:after{
        content:"";
        display:block;
        width:1px;
        height:36px;
        background:#e0e0e0;
        transform-origin:top left;
        transform:rotate(45deg);
        position:absolute;
        left:25px;
        top:12px;
      }
    }
  }
  .motion{
    width:100%;
    height:100%;
    position:absolute;
    top:0;
    left:0;
   // opacity:0;
    background:#fff;
    transition:0.5s;
    visibility:hidden;
  }
  
  @media (min-width:540px){
    .list{
      max-width:540px;
      padding:0 16px;
    }
    .list-item{
      width:50%;
      float:left;
      margin:0 0 8px;
    }
  }
  @media (min-width:768px){
    .list{
      max-width:768px;
    }
    .list-item{
      width:33.3333333%;
    }
  }
  @media (min-width:1024px){
    .list{
      max-width:1024px;
      
    }
    .list-item{
      width:25%;
    }
  }
}

// Loading Animation by @tobiasahlin
.loading-anime{
  display:none;
  position:fixed;
  margin: auto;
  //position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  width: 40px;
  height: 40px;
  z-index:99;
}
.sk-fading-circle {
 // margin: 100px auto;
  width: 40px;
  height: 40px;
  position: relative;
}

.sk-fading-circle .sk-circle {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}

.sk-fading-circle .sk-circle:before {
  content: '';
  display: block;
  margin: 0 auto;
  width: 15%;
  height: 15%;
  background-color: #ccc;
  border-radius: 100%;
  -webkit-animation: sk-circleFadeDelay 1.2s infinite ease-in-out both;
          animation: sk-circleFadeDelay 1.2s infinite ease-in-out both;
}
.sk-fading-circle .sk-circle2 {
  -webkit-transform: rotate(30deg);
      -ms-transform: rotate(30deg);
          transform: rotate(30deg);
}
.sk-fading-circle .sk-circle3 {
  -webkit-transform: rotate(60deg);
      -ms-transform: rotate(60deg);
          transform: rotate(60deg);
}
.sk-fading-circle .sk-circle4 {
  -webkit-transform: rotate(90deg);
      -ms-transform: rotate(90deg);
          transform: rotate(90deg);
}
.sk-fading-circle .sk-circle5 {
  -webkit-transform: rotate(120deg);
      -ms-transform: rotate(120deg);
          transform: rotate(120deg);
}
.sk-fading-circle .sk-circle6 {
  -webkit-transform: rotate(150deg);
      -ms-transform: rotate(150deg);
          transform: rotate(150deg);
}
.sk-fading-circle .sk-circle7 {
  -webkit-transform: rotate(180deg);
      -ms-transform: rotate(180deg);
          transform: rotate(180deg);
}
.sk-fading-circle .sk-circle8 {
  -webkit-transform: rotate(210deg);
      -ms-transform: rotate(210deg);
          transform: rotate(210deg);
}
.sk-fading-circle .sk-circle9 {
  -webkit-transform: rotate(240deg);
      -ms-transform: rotate(240deg);
          transform: rotate(240deg);
}
.sk-fading-circle .sk-circle10 {
  -webkit-transform: rotate(270deg);
      -ms-transform: rotate(270deg);
          transform: rotate(270deg);
}
.sk-fading-circle .sk-circle11 {
  -webkit-transform: rotate(300deg);
      -ms-transform: rotate(300deg);
          transform: rotate(300deg); 
}
.sk-fading-circle .sk-circle12 {
  -webkit-transform: rotate(330deg);
      -ms-transform: rotate(330deg);
          transform: rotate(330deg); 
}
.sk-fading-circle .sk-circle2:before {
  -webkit-animation-delay: -1.1s;
          animation-delay: -1.1s; 
}
.sk-fading-circle .sk-circle3:before {
  -webkit-animation-delay: -1s;
          animation-delay: -1s; 
}
.sk-fading-circle .sk-circle4:before {
  -webkit-animation-delay: -0.9s;
          animation-delay: -0.9s; 
}
.sk-fading-circle .sk-circle5:before {
  -webkit-animation-delay: -0.8s;
          animation-delay: -0.8s; 
}
.sk-fading-circle .sk-circle6:before {
  -webkit-animation-delay: -0.7s;
          animation-delay: -0.7s; 
}
.sk-fading-circle .sk-circle7:before {
  -webkit-animation-delay: -0.6s;
          animation-delay: -0.6s; 
}
.sk-fading-circle .sk-circle8:before {
  -webkit-animation-delay: -0.5s;
          animation-delay: -0.5s; 
}
.sk-fading-circle .sk-circle9:before {
  -webkit-animation-delay: -0.4s;
          animation-delay: -0.4s;
}
.sk-fading-circle .sk-circle10:before {
  -webkit-animation-delay: -0.3s;
          animation-delay: -0.3s;
}
.sk-fading-circle .sk-circle11:before {
  -webkit-animation-delay: -0.2s;
          animation-delay: -0.2s;
}
.sk-fading-circle .sk-circle12:before {
  -webkit-animation-delay: -0.1s;
          animation-delay: -0.1s;
}

@-webkit-keyframes sk-circleFadeDelay {
  0%, 39%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

@keyframes sk-circleFadeDelay {
  0%, 39%, 100% { opacity: 0; }
  40% { opacity: 1; } 
}
            
          
!
            
              //Variables 
var hover_active = false;
var img_src = [];

//DOM ready
$(function() {
  //init
  //----------------------------------
  $('.list-item').addClass('init');
  $('.img').css('height', $('.img').width() * 0.75);

  //Load all thumbnails
  //----------------------------------
  $('.list-item img').each(function(index) {
    //console.log(index);
    //Monitor the loading process
    $(this).onload = loadComplete(index);
    //Execute the loding
    var src = 'https://source.unsplash.com/' + $(this).data('id') + '/400x300';
    $(this).attr('src', src);

  });

  function loadComplete(index) {
    $('.img').eq(index).removeClass('init');
    setTimeout(function() {
      //$('.img').eq(index).css('height','auto');
    }, 500);
  }

  $('.list-item').each(function(i) {
    var t = $(this);
    setTimeout(function() {
      t.removeClass('init');
    }, i * 200);
  });

});

//After loaded
$(window).load(function() {
  var motion_parts_offset;
  var selected_card_w;
  var selected_card_h;

  hover_active = true;

  $('.list-item').hover(function() {
    if (hover_active) {
      $(this).addClass('hover');

      selected_card_w = $(this).width();
      selected_card_h = $(this).height();
      motion_parts_offset = $(this).offset();

      $('.motion').width(selected_card_w).height(selected_card_h).css({
        top: motion_parts_offset.top,
        left: motion_parts_offset.left
      });
    }
  }, function() {
    $(this).removeClass('hover');
  });

  $('.list-item').on('click', function() {

    if (hover_active) {
      hover_active = false;
      $(this).removeClass('hover');

      selected_card_w = $(this).width();
      selected_card_h = $(this).height();
      motion_parts_offset = $(this).offset();
      
      var document_height = $(document).height(); 
      var photo_id = $(this).find('img').data('id');
      $('.motion').width(selected_card_w).height(selected_card_h).css({
        top: motion_parts_offset.top,
        left: motion_parts_offset.left
      });

      $('.motion').css('opacity', 1);
      $('.motion').width('100%').height(document_height).css({
        top: 0,
        left: 0,
        zIndex: 5,
        opacity: 1,
        visibility: 'visible'
      });
    
      setTimeout(function() {
        //$('.page-container').css('display', 'block');
        $('.motion').css('position','fixed');
        $('.loading-anime').show();
        var img = new Image();
        img.src = 'https://source.unsplash.com/' + photo_id + '/1600x1200)';
        img.onload = function() {
          console.log('e');
          $('.page-container').css({
            background: 'url(https://source.unsplash.com/' + photo_id + '/1600x1200) center center',
            backgroundSize: 'cover'
          });
          $('.page-container').fadeIn(1000);
          $('.loading-anime').hide();
        }

      }, 500);
    }
  });

  $('.btn-close').on('click', closePage);
  $('.page-container').on('click', closePage);
  function closePage(){
    $('.page-container').fadeOut();
    $('.motion').css('position','absolute');
    setTimeout(function() {
      hover_active = true;
      $('.page-container').css({
        background: 'none'
      });
    }, 500);
    $('.motion').width(selected_card_w).height(selected_card_h).css({
      top: motion_parts_offset.top,
      left: motion_parts_offset.left,
      zIndex: 0,
      opacity: 0
    }).css('visibility', 'hidden');
    $('.page-container').css('display', 'none');
  }
});

var timer = false;
$(window).on('resize', resize);

function resize() {
  if (timer !== false) {
    clearTimeout(timer);
  }
  timer = setTimeout(function() {
    $('.img').css('height', $('.img').width() * 0.75);
  }, 500);
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console